Repository navigation
feat(#122): server administration and sqlscript in the Go HTTP client - #126
Conversation
Adds typed, *ArcadeDBError-returning facade methods for what a per-user
isolation setup needs, which until now was reachable only through Raw():
- CreateUser, UpdateUser, DropUser, ListUsers, SaveGroup, DeleteGroup and
ListGroups on the dedicated /api/v1/server/users and /groups endpoints
- CreateDatabase and DropDatabase through POST /api/v1/server, refusing an
empty or white-space-padded name the server would silently trim
- ServerCommand, which decodes the body itself because the server answers
{"result":"ok"} where the contract declares an array
- the SQLScript query-language constant
A duplicate user is refused with 403, not the contract's 409, and a
duplicate database with 400; both measured live and pinned in e2e.
Python and TypeScript follow in separate PRs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Upstream issue for the 403-vs-409 mismatch: ArcadeData/arcadedb#10073. If it's fixed to 409, the e2e pin in |
ReviewSolid, well-scoped PR: the facade additions follow the existing patterns in this module closely (same One prose-accuracy issue (affects 3 files)
That's the idempotency-cache collision, unrelated to "user already exists." The contract does not document 409 as the status for a duplicate user — it documents no status at all for that case. So "not the 409 the contract declares" reads as if the contract specifies 409-for-duplicate-user and the server deviates from it, when actually the contract is simply silent on that case and 409 is only the generic REST-convention expectation. Given this repo's rule that this kind of prose is load-bearing and should stay accurate, I'd suggest rewording the three spots to something like "not the 409 a REST convention would suggest" or just "not 409" (dropping the "the contract declares" framing), since a reader who goes to check the contract (as I just did) will not find that declaration and may get confused about where it's coming from. By contrast, the parallel claim for Everything else checked out
Nice attention to the upstream 403-vs-409 and 400 quirks being pinned live rather than assumed — that's exactly the kind of thing that'd otherwise bite a caller silently. |
…ient (#128) * feat(#122): server administration and sqlscript in the Python HTTP client Mirrors the Go surface from #126 on both ArcadeDBServer and AsyncArcadeDBServer, each failure an ArcadeDBError: - create_user, update_user, drop_user, list_users, save_group, delete_group and list_groups on /api/v1/server/users and /groups - create_database and drop_database through POST /api/v1/server, refusing a name the server would silently trim with ValueError - server_command, posting through the pooled httpx client because the generated model raises ValueError on {"result":"ok"} - "sqlscript" in QueryLanguage, which previously failed type-checking A duplicate user is refused with 403 (the contract declares 409, ArcadeData/arcadedb#10073) and a duplicate database with 400; both pinned in e2e, sync and async.
…P client (#130) Completes #122 after Go (#126) and Python (#128). ArcadeDBServer gains, each throwing ArcadeDBError on failure: - createUser, updateUser, dropUser, listUsers, saveGroup, deleteGroup and listGroups on /api/v1/server/users and /groups - createDatabase and dropDatabase through POST /api/v1/server, rejecting a name the server would silently trim with RangeError - serverCommand, returning the parsed body as Record<string, unknown> because the contract types it QueryResponse while admin commands answer {"result":"ok"} - "sqlscript" in QueryLanguage, which previously did not compile A duplicate user is 409 (403 before ArcadeData/arcadedb#10076) and a duplicate database 400; both pinned in e2e. Closes #122
…o) (#129) Upstream fixed #10073 the day #126 merged: creating a user under a taken name now answers 409 instead of 403 "Security error", so the e2e pin in go/e2e/admin_test.go fails against the current SNAPSHOT. Pin 409 and update CreateUser's doc comment, the README and go/CLAUDE.md, noting that older servers answered 403. Also documents, as the Python review of #128 asked, that CreateDatabase sends a name as given beyond the trim check.
Refs #122. This is the Go part only (
go/arcadedb). Python and TypeScript follow in separate PRs, so the issue stays open.Why
A user evaluating the Go driver in place of their own HTTP client found that creating databases and users was reachable only through
Raw(), which never returns an error for a non-2xx status. Their application's per-user isolation depends on those calls. There was also nosqlscriptconstant.What changed
New facade methods on
*Server(go/arcadedb/admin.go). Each one returns an*ArcadeDBErroron a non-2xx status, like every other facade method.CreateUser,UpdateUser,DropUser,ListUsers/api/v1/server/users(POST / PUT / DELETE / GET)SaveGroup,DeleteGroup,ListGroups/api/v1/server/groupsCreateDatabase,DropDatabasePOST /api/v1/serverwithcreate database <name>/drop database <name>ServerCommandPOST /api/v1/server, any command; returns the whole JSON bodyAlso: the
SQLScript QueryLanguage = "sqlscript"constant.Design points:
ServerCommandcalls the plain generated client and decodes the body itself. The typedExecuteServerCommandWithResponsewould reportLimit,ReturnedandTruncatedthe wire never carried, because the server answers{"result":"ok"}where the contract declares an array (a known contract quirk).CreateDatabaseandDropDatabaserefuse an empty name, or one with leading or trailing white space, withErrInvalidNamebefore sending anything. The server trims the name it reads out of the command string, so" db"would act ondb. Injecting a second command isn't possible: the server runs one command per request and takes the rest of the string as the target.UpdateUserzero values. An emptyPasswordand a nilDatabasesare left unchanged. A non-nil emptyDatabasesmap is sent, and removes every assignment."Already exists" is not 409
I measured both cases against a live
26.11.1-SNAPSHOTserver, andgo/e2e/admin_test.gopins them:Security error, withDetail: User '<name>' already existsCannot execute command, withDetail: Database '<name>' already existsThe 403 comes from
ServerSecurityExceptionbeing mapped to 403 by the server's HTTP layer, which is the same status a non-root caller gets. The client therefore classifies neither case. The README tells callers to checkListUsersorExistsfirst if they want to create only when something is missing. The 403-vs-409 mismatch is an upstream contract/server disagreement; I haven't filed it yet.Docs
go/arcadedb/README.md: a new "Administration: databases, users and groups" section, the language list, and a rewrite of the passage that saidPOST /api/v1/serverwas not wrapped.go/CLAUDE.md: contract quirk 2 now points atServerCommandand records both measured statuses.Completeness
Goal: every administration call a per-tenant setup needs can be made through the Go facade, with typed errors, and
sqlscripthas a named constant.ServerCommand)list databases)SQLScripte2e/main_test.go'snewDatabasestill builds the server command by handNot covered by this PR: the Python and TypeScript halves of #122, and the upstream 403/409 mismatch.
Verification
go test -race ./...ingo/arcadedb: 170 tests pass.go test ./...ingo/e2e: all 37 tests pass, none skipped.scripts/check-drift.sh: clean (no generated code touched).scripts/lint.sh: clean on Go 1.26.7, the CI floor. On Go 1.27 the pinned staticcheck can't read the compiled standard library, and that fails onmaintoo.🤖 Generated with Claude Code