Skip to content

feat(#122): server administration and sqlscript in the Go HTTP client - #126

Merged
robfrank merged 1 commit into
mainfrom
feat/122-go-server-commands
Oct 15, 2026
Merged

robfrank merged 1 commit into
mainfrom
feat/122-go-server-commands

Conversation

@robfrank

Copy link
Copy Markdown
Contributor

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 no sqlscript constant.

What changed

New facade methods on *Server (go/arcadedb/admin.go). Each one returns an *ArcadeDBError on a non-2xx status, like every other facade method.

Method Endpoint
CreateUser, UpdateUser, DropUser, ListUsers /api/v1/server/users (POST / PUT / DELETE / GET)
SaveGroup, DeleteGroup, ListGroups /api/v1/server/groups
CreateDatabase, DropDatabase POST /api/v1/server with create database <name> / drop database <name>
ServerCommand POST /api/v1/server, any command; returns the whole JSON body

Also: the SQLScript QueryLanguage = "sqlscript" constant.

Design points:

  • Body decoding. ServerCommand calls the plain generated client and decodes the body itself. The typed ExecuteServerCommandWithResponse would report Limit, Returned and Truncated the wire never carried, because the server answers {"result":"ok"} where the contract declares an array (a known contract quirk).
  • Database names. CreateDatabase and DropDatabase refuse an empty name, or one with leading or trailing white space, with ErrInvalidName before sending anything. The server trims the name it reads out of the command string, so " db" would act on db. Injecting a second command isn't possible: the server runs one command per request and takes the rest of the string as the target.
  • UpdateUser zero values. An empty Password and a nil Databases are left unchanged. A non-nil empty Databases map is sent, and removes every assignment.

"Already exists" is not 409

I measured both cases against a live 26.11.1-SNAPSHOT server, and go/e2e/admin_test.go pins them:

Case Contract Server
Duplicate user 409 403 Security error, with Detail: User '<name>' already exists
Duplicate database — 400 Cannot execute command, with Detail: Database '<name>' already exists

The 403 comes from ServerSecurityException being 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 check ListUsers or Exists first 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 said POST /api/v1/server was not wrapped.
  • go/CLAUDE.md: contract quirk 2 now points at ServerCommand and 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 sqlscript has a named constant.

Entry point Covered Tested
users: create / update / drop / list yes unit (request shape, each error status) + e2e
groups: save / delete / list yes unit + e2e
create / drop database yes unit (incl. name refusal, no request sent) + e2e (incl. duplicate and missing)
any other server command (ServerCommand) yes unit (body, errors, empty body) + e2e (list databases)
SQLScript yes unit (wire value) + e2e (multi-statement script)
Python and TypeScript HTTP clients no still open in #122
e2e/main_test.go's newDatabase still builds the server command by hand no left as is: it's an existing test helper and still works

Not covered by this PR: the Python and TypeScript halves of #122, and the upstream 403/409 mismatch.

Verification

  • go test -race ./... in go/arcadedb: 170 tests pass.
  • go test ./... in go/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 on main too.

🤖 Generated with Claude Code

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>
@robfrank robfrank added enhancement New feature or request go Go client workspace (planned) http-driver arcadedb-driver, the HTTP client generated from the OpenAPI contract labels Oct 15, 2026
@robfrank

Copy link
Copy Markdown
Contributor Author

Upstream issue for the 403-vs-409 mismatch: ArcadeData/arcadedb#10073. If it's fixed to 409, the e2e pin in go/e2e/admin_test.go will fail on the contract refresh and needs updating, along with the README and go/CLAUDE.md prose.

@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review

Solid, well-scoped PR: the facade additions follow the existing patterns in this module closely (same checkResponse/decodeBody/decodeMap plumbing as server.go, same "generated request type as parameter" precedent as vector.go), the generated client usages (CreateUserWithResponse, UpdateUserWithResponse, DeleteUserWithResponse, ListUsersWithResponse, ListGroupsWithResponse, CreateOrUpdateGroupWithResponse, DeleteGroupWithResponse, ExecuteServerCommandWithBody) all match the generated signatures in client.gen.go, and nothing under generated/ was touched — no drift-gate risk. contracts/ still holds exactly one OpenAPI file and one .proto. Test coverage is thorough: unit tests cover request shape, zero-value semantics, and every documented error status; the e2e suite exercises the real per-tenant-isolation use case end to end, including the measured 400/403 "already exists" statuses.

One prose-accuracy issue (affects 3 files)

admin.go's CreateUser doc comment, go/arcadedb/README.md, and go/CLAUDE.md's quirk #2 all say a duplicate user is refused with 403 "not the 409 the contract declares" / "although the contract declares 409 for createUser". I checked the committed contract (contracts/arcadedb-openapi-26.11.1-SNAPSHOT.json, operation createUser around line 14359): its only 409 response is:

"An identical request with the same 'X-Request-Id' is still executing... The body names RequestStillInFlightException."

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 CreateDatabase/DropDatabase ("not a 409") doesn't make the "contract declares" claim and is accurate as written — the contract's executeServerCommand operation declares no status for "database already exists" either, and the prose there correctly doesn't assert otherwise.

Everything else checked out

  • databaseCommand's empty/whitespace-trim refusal (ErrInvalidName) correctly precedes any network call, matches the server's documented trimming behavior, and is unit-tested for all the relevant whitespace variants.
  • ServerCommand's bypass of the typed ExecuteServerCommandWithResponse is well-justified and consistent with the same workaround already used for TS().Query/Grafana().Query elsewhere in this client.
  • UpdateUser's zero-value handling (empty password / nil vs. non-nil-empty Databases map) matches UpdateUserRequest's pointer-typed optional fields in the generated model, and is both unit- and e2e-tested (the "clear all assignments" case included).
  • The README's edit from "security" to "API-token" in the "Endpoints this client does not wrap" section is accurate — I checked the contract's Security-tagged operations, and this PR wraps all of them (createUser, updateUser, deleteUser, listUsers, createOrUpdateGroup, deleteGroup, listGroups) except createApiToken/listApiTokens/deleteApiToken, which remain Raw()-only.
  • No new dependencies were introduced, so no license-compliance impact.

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.

@robfrank
robfrank merged commit 96f17c0 into main Oct 15, 2026
robfrank added a commit that referenced this pull request Oct 15, 2026
…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.
robfrank added a commit that referenced this pull request Oct 15, 2026
…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
robfrank added a commit that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Go client workspace (planned) http-driver arcadedb-driver, the HTTP client generated from the OpenAPI contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant