Repository navigation
Description
"500", "SchemaException", "CommandExecutionException". The only hits are #10073 (user, CLOSED),
#10074 (database, CLOSED), #10075 (Java client types, CLOSED) and #10110 (OpenAPI wording for the
token 409). None of them covers a schema object. This is the complement of those three fixes, not a
restatement of them.
4xx-or-5xx by accident. Table below. Six affected, so ONE finding carrying the table.
Summary
The rule the three fixes established is: a name that is already taken is a conflict, answered 409,
logged as a user error. AbstractServerHttpHandler.classifyError now implements that rule for
exactly three exception types - UserAlreadyExistsException, DatabaseAlreadyExistsException and
(by the handler's own setStatusCode) ServerControlPlane$AlreadyExistsException. Every other
"already exists" condition in the product raises either a bare CommandExecutionException or a bare
SchemaException, neither of which has a conflict arm, so it falls through to the generic
500 "Cannot execute command" / 500 "Internal error" arms at the bottom of the chain.
Two consequences, both of which are what #10073/#10074 were filed about:
- A client cannot tell a taken name from a server fault. Every retry policy, load balancer and
driver that keys on 5xx will retry aCREATE TYPEthat can only ever be refused again. The
DuplicatedKeyExceptionarm states this rationale explicitly ("503 told clients/load balancers
the request was retry-worthy, amplifying the bad write") - the same argument applies verbatim
here and was not carried across. - The server logs a full stack trace at SEVERE for an ordinary client mistake. The 500 arms are
ErrorLogKind.INTERNAL_COMMAND, which passes the throwable to the logger. Six SEVERE stack
traces were produced by the six refusals in the repro below. Replaying a duplicateCREATE TYPE
in a loop is an unauthenticated-after-login log-flood primitive; the 409 arms are
ErrorLogKind.USER(message only, flood-protected level) precisely to avoid that.
Where (HEAD ee6a5b8)
server/src/main/java/com/arcadedb/server/http/handler/AbstractServerHttpHandler.java
classifyError, lines ~1236-1249: the two new conflict arms. There is no arm for
SchemaException,TypeAlreadyExistsExceptionor aCommandExecutionExceptioncarrying a taken
name, so they reach theCommandExecutionExceptionarm (500) and the finalreturn new ErrorClassification(500, "Internal error", ...)respectively.- The refusal sites that have no type to match on (
git grep -n "already exists" -- '*/src/main/java/*'):engine/.../query/sql/parser/CreateTypeAbstractStatement.java:120CommandExecutionException("Type " + typeName + " already exists")engine/.../query/sql/parser/CreatePropertyStatement.java:107CommandExecutionException("Property '...' already exists")engine/.../query/sql/parser/CreateIndexStatement.java:372CommandExecutionException("Index '...' already exists")engine/.../query/sql/parser/CreateBucketStatement.java:59CommandExecutionException("Bucket '...' already exists")engine/.../query/sql/parser/CreateTimeSeriesTypeStatement.java:106,CreateTriggerStatement.java:130,
CreateGraphAnalyticalViewStatement.java:70- same shapeengine/.../schema/MaterializedViewBuilder.java:252andContinuousAggregateBuilder.java:143SchemaExceptionengine/.../schema/LocalSchema.java:1853(bucket),:2323(trigger),:5347(index)SchemaExceptionengine/.../schema/TypeBuilder.java:204raises the one type that does exist,
com.arcadedb.exception.TypeAlreadyExistsException- and it extendsSchemaException, which has
no arm, so it too is a 500.
Repro
Server started with -Darcadedb.server.httpIncomingPort=12480 (2480 is taken on this host),
-Darcadedb.server.rootPassword=..., mode development. Each command below was issued twice; the
second answer is shown.
POST /api/v1/server create database census
-> 409 {"error":"Database already exists","exception":"com.arcadedb.server.DatabaseAlreadyExistsException"}
POST /api/v1/server create user {"name":"user1",...}
-> 409 {"error":"User already exists","exception":"com.arcadedb.server.security.UserAlreadyExistsException"}
POST /api/v1/server/users {"name":"user2",...}
-> 409 {"error":"User already exists", ...}
POST /api/v1/server/api-tokens {"name":"tok1","user":"user1"}
-> 409 {"error":"A token with name 'tok1' already exists","exception":"...ServerControlPlane$AlreadyExistsException"}
POST /api/v1/command/census {"command":"create vertex type V1","language":"sql"}
-> 500 {"error":"Cannot execute command","exception":"com.arcadedb.exception.CommandExecutionException","detail":"Type V1 already exists"}
POST /api/v1/command/census {"command":"create edge type V1","language":"sql"} (name taken by a vertex type)
-> 500 {"error":"Cannot execute command", ... "detail":"Type V1 already exists"}
POST /api/v1/command/census {"command":"create property V1.p1 string","language":"sql"}
-> 500 {"error":"Cannot execute command", ... "detail":"Property 'V1.p1' already exists"}
POST /api/v1/command/census {"command":"create index on V1 (p1) unique","language":"sql"}
-> 500 {"error":"Cannot execute command", ... "detail":"Index 'V1[p1]' already exists"}
POST /api/v1/command/census {"command":"create bucket b1","language":"sql"}
-> 500 {"error":"Cannot execute command", ... "detail":"Bucket 'b1' already exists"}
POST /api/v1/command/census {"command":"create materialized view mv1 as select from V1","language":"sql"}
-> 500 {"error":"Internal error","exception":"com.arcadedb.exception.SchemaException","detail":"Materialized view 'mv1' already exists"}
Server-side, each of those six produced a SEVERE line WITH a stack trace, e.g.
SEVER [PostCommandHandler] <ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.SchemaException: Materialized view 'mv1' already exists
at com.arcadedb.schema.MaterializedViewBuilder.create(MaterializedViewBuilder.java:252)
at com.arcadedb.query.sql.parser.CreateMaterializedViewStatement.executeDDL(...)
Two near neighbours that are 4xx but still not 409, for completeness:
ALTER TYPE D1 NAME V1 (rename onto a taken name) -> 400, java.lang.IllegalArgumentException
"Type with name 'V1' already exists"
Cypher CREATE CONSTRAINT duplicating an index -> 400, java.lang.IllegalArgumentException
Note the materialized-view case is the worst of the set: SchemaException extends ArcadeDBException
directly, so it does not even reach the CommandExecutionException arm and is reported to the client
as the unqualified "Internal error".
Census table (all rows produced by the commands above against this build):
| Taken name | Route | Exception raised | Status today | Should be |
|---|---|---|---|---|
| database | POST /api/v1/server create database |
DatabaseAlreadyExistsException |
409 | 409 (#10074) |
| user | POST /api/v1/server create user, POST /api/v1/server/users |
UserAlreadyExistsException |
409 | 409 (#10073) |
| API token | POST /api/v1/server/api-tokens | ServerControlPlane$AlreadyExistsException |
409 | 409 |
| type (document/vertex/edge) | POST /api/v1/command/{db} | CommandExecutionException |
500 | 409 |
| property | POST /api/v1/command/{db} | CommandExecutionException |
500 | 409 |
| index | POST /api/v1/command/{db} | CommandExecutionException |
500 | 409 |
| bucket | POST /api/v1/command/{db} | CommandExecutionException |
500 | 409 |
| materialized view | POST /api/v1/command/{db} | SchemaException |
500 "Internal error" | 409 |
| type rename onto a taken name | POST /api/v1/command/{db} | IllegalArgumentException |
400 | 409 |
Not exhaustively enumerated: continuous aggregate, trigger, time-series type and graph analytical
view raise the same two bare types at the sites listed above, so they classify identically, but I
could not get their DDL grammar right from the parser error messages and so did not observe them on
the wire. They are listed as code-read, not as measured rows.
The same gap on the other three wires (same rule, same root cause)
The other transports do not read classifyError; they read ErrorCategory.of(error), the shared
classifier (engine/src/main/java/com/arcadedb/exception/ErrorCategory.java). It has no
"already exists" category either, so the same two exception types fall into SERVER (a server
fault) and SCHEMA (meaning "the schema does not define this"). Reproduced by calling the two
mappers directly on the exact exceptions the statements raise, on classes built from HEAD:
ErrorCategory Postgres SQLSTATE Bolt code
CREATE TYPE on a taken name SERVER XX000 Neo.DatabaseError.General.UnknownError
CREATE PROPERTY on a taken name SERVER XX000 (same)
CREATE INDEX on a taken name SERVER XX000 (same)
CREATE BUCKET on a taken name SERVER XX000 (same)
CREATE MATERIALIZED VIEW on taken name SCHEMA 42P01 Neo.ClientError.Statement.SemanticError
TypeAlreadyExistsException (TypeBuilder) SCHEMA 42P01 Neo.ClientError.Statement.SemanticError
(PostgresNetworkExecutor.sqlStateFor, BoltNetworkExecutor.classifyExecutionError, both invoked
directly from a probe in their own package.)
Two things are wrong here beyond the HTTP status:
XX000isinternal_error: a Postgres client is told the server broke because it issued the
equivalent ofCREATE TABLEtwice. Postgres' own codes for this are42P07 duplicate_tableand
42710 duplicate_object, neither of which ArcadeDB ever sends.42P01isundefined_table- it says the object does NOT exist, which is the exact opposite of
the refusal. Same inversion on Bolt, whereSemanticErroris documented in this code base as
"the caller named a type, bucket or property the schema does not define".
Suggested fix
The guard belongs at the AUTHORITY, not at a third call site. TypeAlreadyExistsException already
exists in the engine and is already thrown by TypeBuilder; promote it (and a sibling for the other
schema objects, or one AlreadyExistsException base in com.arcadedb.exception) to the type every
"already exists" site raises, then add ONE arm to classifyError keyed on that base, above the
CommandExecutionException arm and with ErrorLogKind.USER. The statement classes then stop
hand-rolling CommandExecutionException("... already exists").
The guarantee that stops it coming back is a test over the refusal sites rather than over the three
routes: a unit test that reflects over com.arcadedb.query.sql.parser.Create*Statement /
com.arcadedb.schema.*Builder, or simply a git grep "already exists" assertion in the build,
proving no site raises a type that classifyError maps to 5xx. The existing per-issue ITs
(Issue10073DuplicateUserAnswers409IT, Issue10074TakenDatabaseNameAnswers409IT) pin one name
each and cannot see the six that were left behind - which is exactly how three fixes landed without
noticing them.
Scope / confidence
Reproduced end to end against a locally started server built from HEAD. The 500s are not a
development-mode artefact: detail is concealed in production mode, which makes the production
answer 500 "Cannot execute command" with no indication at all that the name was taken.
Activity
review: race test for cache resizes, MostUsedCache(0) coverage, simpl…
review: inherited property name collisions and a late type-rename col…
Merge pull request #10179 from ArcadeData/worktree-arcadedb-10153-101…
lvca commentedon Oct 16, 2026
Fixed in #10179 (26.11.1).
Creating or renaming a schema object onto a name that is already taken is now reported as a conflict everywhere, instead of a server error. This covers types, properties, indexes, constraints, buckets, triggers, views and functions.
409, witherrornaming the kind (e.g.Type already exists), instead of500. No more SEVERE stack trace in the server log.42P07(type, index, view),42701(property),42710(other), instead ofXX000/42P01.Neo.ClientError.Schema.*AlreadyExistscodes.ALREADY_EXISTS. MongoDB:NamespaceExists.Java API and clients: all these refusals now throw
com.arcadedb.exception.AlreadyExistsException, aSchemaException, and the remote clients rebuild it. Code that caughtIllegalArgumentExceptionorCommandExecutionExceptionfor this case should catchAlreadyExistsExceptioninstead.❤️ 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.
fix: taken schema names answer a conflict, setting changes clear ever…
fix(spork): a taken selection name raises AlreadyExistsException (Arc…
fix: taken schema names answer a conflict, setting changes clear ever…
review: race test for cache resizes, MostUsedCache(0) coverage, simpl…
review: inherited property name collisions and a late type-rename col…
test(ArcadeData#10153): allow-list the CREATE INDEX conflict under it…
HANDOFF.md: record the ArcadeData#10153 allow-list gotcha and the Arc…
test(postgresw): consolidate the issue-named postgresw tests into top…