Database resource types advertise write capability but handler rejects remote writes #9577

Closed
opened 2026-04-14 23:35:51 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit: main (HEAD on 2026-04-14)
  • Branch: main

Background and Context

PostgreSQL and MySQL resource type definitions declare capabilities.write: true in src/cleveragents/resource/handlers/database.py (POSTGRES_TYPE_DEF and MYSQL_TYPE_DEF). However, the shared DatabaseResourceHandler.write implementation falls through to the remote branch and immediately returns success=False with the message "write() is not supported for remote database type 'postgres'" whenever _is_sqlite_resource is false.

This mismatch means the CLI and any automation that inspects capabilities will advertise write support for remote database resources — and then silently fail every time a write is attempted. Users have no way to know the operation will fail until they try it.

Expected Behavior

Either:

  1. DatabaseResourceHandler.write is implemented for remote database types (PostgreSQL, MySQL) so that write operations actually succeed, or
  2. POSTGRES_TYPE_DEF and MYSQL_TYPE_DEF set capabilities.write: false so the CLI correctly refuses to offer the write operation before it is attempted.

In either case, the advertised capability must match the actual runtime behaviour.

Acceptance Criteria

  • agents resource type show postgres does not list write as a supported capability unless remote writes are actually implemented.
  • agents resource type show mysql does not list write as a supported capability unless remote writes are actually implemented.
  • Attempting agents resource content write --resource <postgres-resource> --data "..." either succeeds (if write is implemented) or is rejected by the CLI before reaching the handler (if capability is removed).
  • No regression on SQLite resource write behaviour.
  • Unit tests cover the corrected capability declaration and/or the new write implementation path.

Subtasks

  • Audit POSTGRES_TYPE_DEF and MYSQL_TYPE_DEF capability declarations in database.py.
  • Decide: implement remote write support or set write: false for remote types.
  • If implementing write: add SQL execution path in DatabaseResourceHandler.write for remote connections.
  • If removing capability: update both type defs and add a regression test asserting write is absent.
  • Update or add unit tests to cover the chosen fix.
  • Verify agents resource type show postgres and agents resource type show mysql output reflects the corrected capability.

Definition of Done

This issue should be closed when:

  • The advertised write capability for PostgreSQL and MySQL resource types matches the actual handler behaviour (either both work or both are absent).
  • All existing tests pass and new tests cover the fix.
  • No CLI path allows a user to attempt a write on a remote database resource that will silently fail due to this mismatch.

Steps to Reproduce

  1. Run agents resource type show postgres — note write is listed as supported.
  2. Register a postgres resource: agents resource add dbtest --type postgres --property connection-string=postgresql://user:pass@localhost:5432/example.
  3. Attempt a write: agents resource content write --resource dbtest --data "CREATE TABLE demo(id INT);".
  4. Observe success=False with "write() is not supported for remote database type 'postgres'".

Supporting Evidence

  • src/cleveragents/resource/handlers/database.py: POSTGRES_TYPE_DEF and MYSQL_TYPE_DEF both declare { "write": True } in their capabilities dicts.
  • src/cleveragents/resource/handlers/database.py: DatabaseResourceHandler.write returns a failure with the "write() is not supported" message whenever _is_sqlite_resource is false.

Environment

  • Repository: cleveragents/cleveragents-core
  • Branch: main (HEAD on 2026-04-14)
  • Tooling: agents CLI current in this repository

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit:** `main` (HEAD on 2026-04-14) - **Branch:** `main` ## Background and Context PostgreSQL and MySQL resource type definitions declare `capabilities.write: true` in `src/cleveragents/resource/handlers/database.py` (`POSTGRES_TYPE_DEF` and `MYSQL_TYPE_DEF`). However, the shared `DatabaseResourceHandler.write` implementation falls through to the remote branch and immediately returns `success=False` with the message `"write() is not supported for remote database type 'postgres'"` whenever `_is_sqlite_resource` is false. This mismatch means the CLI and any automation that inspects capabilities will advertise write support for remote database resources — and then silently fail every time a write is attempted. Users have no way to know the operation will fail until they try it. ## Expected Behavior Either: 1. `DatabaseResourceHandler.write` is implemented for remote database types (PostgreSQL, MySQL) so that write operations actually succeed, **or** 2. `POSTGRES_TYPE_DEF` and `MYSQL_TYPE_DEF` set `capabilities.write: false` so the CLI correctly refuses to offer the write operation before it is attempted. In either case, the advertised capability must match the actual runtime behaviour. ## Acceptance Criteria - [ ] `agents resource type show postgres` does **not** list `write` as a supported capability unless remote writes are actually implemented. - [ ] `agents resource type show mysql` does **not** list `write` as a supported capability unless remote writes are actually implemented. - [ ] Attempting `agents resource content write --resource <postgres-resource> --data "..."` either succeeds (if write is implemented) or is rejected by the CLI before reaching the handler (if capability is removed). - [ ] No regression on SQLite resource write behaviour. - [ ] Unit tests cover the corrected capability declaration and/or the new write implementation path. ## Subtasks - [ ] Audit `POSTGRES_TYPE_DEF` and `MYSQL_TYPE_DEF` capability declarations in `database.py`. - [ ] Decide: implement remote write support **or** set `write: false` for remote types. - [ ] If implementing write: add SQL execution path in `DatabaseResourceHandler.write` for remote connections. - [ ] If removing capability: update both type defs and add a regression test asserting `write` is absent. - [ ] Update or add unit tests to cover the chosen fix. - [ ] Verify `agents resource type show postgres` and `agents resource type show mysql` output reflects the corrected capability. ## Definition of Done This issue should be closed when: - The advertised `write` capability for PostgreSQL and MySQL resource types matches the actual handler behaviour (either both work or both are absent). - All existing tests pass and new tests cover the fix. - No CLI path allows a user to attempt a write on a remote database resource that will silently fail due to this mismatch. --- ## Steps to Reproduce 1. Run `agents resource type show postgres` — note `write` is listed as supported. 2. Register a postgres resource: `agents resource add dbtest --type postgres --property connection-string=postgresql://user:pass@localhost:5432/example`. 3. Attempt a write: `agents resource content write --resource dbtest --data "CREATE TABLE demo(id INT);"`. 4. Observe `success=False` with `"write() is not supported for remote database type 'postgres'"`. ## Supporting Evidence - `src/cleveragents/resource/handlers/database.py`: `POSTGRES_TYPE_DEF` and `MYSQL_TYPE_DEF` both declare `{ "write": True }` in their capabilities dicts. - `src/cleveragents/resource/handlers/database.py`: `DatabaseResourceHandler.write` returns a failure with the "write() is not supported" message whenever `_is_sqlite_resource` is false. ## Environment - **Repository:** cleveragents/cleveragents-core - **Branch:** main (HEAD on 2026-04-14) - **Tooling:** agents CLI current in this repository --- **Automated by CleverAgents Bot** Agent: new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9577
No description provided.