Skip to content

POST /api/v1/server/users answers 403 'Security error' for an existing user; the contract declares 409 #10073

Closed

Description

@robfrank

Summary

The server answers POST /api/v1/server/users with 403 Security error when the user name already exists. The OpenAPI contract for createUser declares 409 for that case. Because 403 is also what a non-root caller gets, a client cannot tell "this user already exists" apart from "you may not do this" without matching on the detail text.

Reproduce (26.11.1-SNAPSHOT image, pulled 2026-10-15)

curl -s -u root:playwithdata -H 'Content-Type: application/json' \
  -d '{"name":"alice","password":"a-long-password"}' http://localhost:2480/api/v1/server/users   # 201
curl -s -u root:playwithdata -H 'Content-Type: application/json' \
  -d '{"name":"alice","password":"a-long-password"}' http://localhost:2480/api/v1/server/users   # 403

The second call answers:

403 {"error":"Security error","detail":"User 'alice' already exists", ...}

The contract, paths["/api/v1/server/users"].post.responses, lists 201, 400, 401, 403, 409, 500, 504.

Cause

PostUserHandler → ServerSecurity.createUserClusterWide (and createUser on the non-HA path) throws ServerSecurityException("User '<name>' already exists"). AbstractServerHttpHandler.isSecurityFailure treats every ServerSecurityException as a security failure and maps it to 403 "Security error".

Why it matters

A multi-tenant application that provisions a user per tenant wants create-if-absent. With 409 it can treat the conflict as success. With 403 it has to either string-match detail or list users first, which is racy. The Go client in arcadedb-drivers (ArcadeData/arcadedb-drivers#126) documents the 403 and pins it in its e2e suite rather than classifying it. The Python and TypeScript clients will do the same until this is resolved.

Suggested fix

Either:

  1. Throw a non-security exception for the duplicate, for example a dedicated UserAlreadyExistsException, mapped to 409. This matches the contract and HTTP semantics, and keeps 403 meaning "not authorized". Or
  2. If 403 is intended, change the contract to drop 409 and describe the 403.

Option 1 seems right. The same check may be worth doing for createOrUpdateGroup and createApiToken, whose contracts also declare 409.

Related observation (not necessarily a bug)

create database <name> through POST /api/v1/server on an existing name answers 400 Cannot execute command, with detail: "Database '<name>' already exists" (an IllegalArgumentException). A 409 there would give clients the same create-if-absent signal.

Activity

  1. added
    server
    on Oct 15, 2026
  2. added
    severity:minor
    on Oct 15, 2026
  3. self-assigned this
    on Oct 15, 2026
  4. added this to the 26.11.1 milestone on Oct 15, 2026
  5. added
    in progress
    on Oct 15, 2026
  6. added a commit that references this issue on Oct 15, 2026
  7. robfrank commented on Oct 15, 2026

    @robfrank
    CollaboratorAuthor

    Fixed in #10076. Creating a user under a name that already exists was reported as a security refusal, so it answered 403, the same status a caller who is not root gets. It is now reported as a conflict: 409 on POST /api/v1/server/users and on the create user server command, and ALREADY_EXISTS over gRPC. The createUser contract documents the 409. A caller who is not root still gets 403, so a client can now treat 409 as "already there" for create-if-absent. Suggested sibling checks: createApiToken already answered 409 for a taken name, and createOrUpdateGroup is an upsert, so it cannot conflict.

    Note for Java users: RemoteServer.createUser on a taken name now throws a RemoteException whose message names the conflict, instead of a SecurityException.

    Still open:


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. removed
    in progress
    on Oct 15, 2026
  9. added 2 commits that reference this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugsecurityserverseverity:minor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions