How to Configure OpenHands CockroachDB Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up openhands cockroachdb prevent delete rules, limit your database role rights. You must remove drop and delete rights from the user role your agent uses. Many teams give AI coding agents full database admin roles during early testing. Broad roles let an agent wipe whole tables if a prompt goes wrong. Fixing a lost production table takes hours and hurts your users. How openhands cockroachdb prevent delete works OpenHands is an AI agent that writes code and runs commands for your team.

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To set up openhands cockroachdb prevent delete rules, limit your database role rights. You must remove drop and delete rights from the user role your agent uses. Many teams give AI coding agents full database admin roles during early testing. Broad roles let an agent wipe whole tables if a prompt goes wrong. Fixing a lost production table takes hours and hurts your users.

How openhands cockroachdb prevent delete works

OpenHands is an AI agent that writes code and runs commands for your team. It connects to CockroachDB using a standard database user and password string. CockroachDB checks user roles to see what commands a session can run. You create a custom role in the database just for the AI agent.

Then you grant only read, insert, and update rights to that specific role. You leave out the delete right and the drop table right on purpose. When the agent tries to remove rows, the database blocks the query right away. The database sends an error message back to the agent workspace.

The agent reads this error and knows it cannot remove the data. You should also remove rights that let the role change schema tables. Schema rights often let a user drop columns or wipe table data fast. Keep schema changes with a separate admin role that the agent never uses. This setup forms a solid base for safe AI database work.

What native database roles solve and miss

Native database roles stop basic delete commands at the table level very well. They decide who can log in and which tables that user can touch. This setup works well when an agent only needs to add new records. Yet static roles have a hard time with everyday maintenance work.

Sometimes an agent needs to clean up one bad test row it just made. If you block all deletes on the role, the agent cannot fix its mistake. If you allow deletes on the role, the agent can wipe the whole table. Native database roles cannot tell a single row delete from a full table wipe.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

They also cannot stop an update query that blanks out every user email. An update command without a filter clause can ruin data just like a delete. Static database roles also leave raw data open in query results. When the agent reads a table, it gets every field in plain text. If the table holds card numbers or phone numbers, the agent gets them all.

Why query checks and data masking matter

Safe AI agent access needs checks on each query before it runs. Your team needs a way to read the exact SQL statement in flight. That way you can block a broad delete while allowing a safe one. You can also hold risky queries until a human on your team approves them.

Data masking is the other big piece of safe agent work. Masking rewrites matched fields like emails and national IDs in the query results. The agent still gets the table shape it needs to write good code. Your team keeps private user details out of AI model logs.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can an AI agent still ruin data without delete rights?

Yes, an agent with update rights can overwrite rows with blank or fake values. If the update query lacks a filter, it changes every row in the table. You must check update queries just as closely as delete commands.

Should OpenHands share a database role with human developers?

No, you should always make a separate role just for the AI agent. Separate roles make it easy to check database logs and track agent actions. You can also cut off agent rights fast without locking out your team.

How do we handle database schema updates with an AI agent?

Let the agent write the schema change file in your code repo first. Do not let the agent run schema changes straight against the live database. Have a team member review the file and run it through your deploy tool.

The query runs. The emails stay hidden.