Skip to content

SQL: the DDL statements answer HTTP 500 for a caller's mistake: CREATE TYPE ... BUCKET <id> crashes with a NullPointerException, CREATE PROPERTY with a bare-word constraint or over records that do not satisfy it, DROP BUCKET of a bucket that belongs to a type #12436

Closed

Description

@shaunpatterson

Summary

Five DDL statements that fail on a caller's mistake answer HTTP 500 Internal error. One of them crashes with a raw java.lang.NullPointerException.

The HTTP API reference lists 400 invalid language, invalid query and 400 invalid command for a statement the server refuses to run, and reserves 500 cannot execute query for a failure of the server itself.

statement answer
CREATE DOCUMENT TYPE WithBuckets BUCKET 1,2,3 500 java.lang.NullPointerException: Cannot invoke "com.arcadedb.query.sql.parser.Identifier.getStringValue()" because "b.bucketName" is null
CREATE PROPERTY T.bad STRING (mandatory maybe) 500 CommandExecutionException: The value maybe of MANDATORY is a field reference, not a value: there is no record to read it from, so it would be read as null. Quote it as 'maybe' to use it as a text
CREATE PROPERTY T.bad2 STRING (regexp abc) 500 CommandExecutionException: The value abc of REGEXP is a field reference, not a value: ... Quote it as 'abc' to use it as a text, or write null to remove the attribute
CREATE PROPERTY T.m STRING (mandatory true) over records that do not satisfy it 500 CommandExecutionException: Cannot create property 'T.m': record #1:0 violates it, property 'T.m' is mandatory, but was never set. Fix or delete the non-conforming records first
DROP BUCKET T_0 (a bucket that belongs to a type) 500 CommandExecutionException: Cannot drop bucket 'T_0' because used by type 'T'

The messages of the four CommandExecutionException cases name the problem and say what to do, so only the status is wrong there. The first one is a crash: the statement takes the bucket names the page documents, and a numeric bucket id, which the page also documents, reaches a null name.

Reproduce

Fresh database, T a document type with one record, one HTTP call per statement (POST /api/v1/command/<db>, language sql):

CREATE DOCUMENT TYPE T
CREATE PROPERTY T.x STRING
INSERT INTO T SET x = 'a'
CREATE DOCUMENT TYPE WithBuckets BUCKET 1,2,3
{"error": "Internal error",
 "exception": "java.lang.NullPointerException",
 "detail": "Cannot invoke \"com.arcadedb.query.sql.parser.Identifier.getStringValue()\" because \"b.bucketName\" is null"}
CREATE PROPERTY T.bad STRING (mandatory maybe)
{"error": "Internal error",
 "exception": "com.arcadedb.exception.CommandExecutionException",
 "detail": "The value `maybe` of MANDATORY is a field reference, not a value: there is no record to read it from, so it would be read as null. Quote it as 'maybe' to use it as a text"}
CREATE PROPERTY T.m STRING (mandatory true)
{"error": "Internal error",
 "exception": "com.arcadedb.exception.CommandExecutionException",
 "detail": "Cannot create property 'T.m': record #1:0 violates it, property 'T.m' is mandatory, but was never set. Fix or delete the non-conforming records first"}
DROP BUCKET T_0
{"error": "Internal error",
 "exception": "com.arcadedb.exception.CommandExecutionException",
 "detail": "Cannot drop bucket 'T_0' because used by type 'T'"}

The refusal of the mandatory property is the one the reference page describes:

When you create a property, ArcadeDB reads the records already stored in the type (including its subtypes) and checks them against the declaration: the declared type ..., mandatory, notnull, min, max and regexp. If a record does not satisfy the declaration, the statement fails, names the first offending record, and the property is not created.

and the refusal of a bucket that belongs to a type is the one the buckets page describes:

A bucket belongs to one type only. The statement is refused when a bucket it would attach already belongs to another type ...

Measured on

  • arcadedata/arcadedb:26.12.1-SNAPSHOT with the engine, server and network jars of main 1541bf7f9f9a3f670a54e42b05c1071cc9c3a514 in /home/arcadedb/lib
  • arcadedata/arcadedb:26.10.1 (the released image), which answers the same for every statement of the table (the message of the mandatory maybe case is the older one, and the regexp abc case is accepted there instead of being refused)

Expected

The statements are refused with HTTP 400 and the message that names the problem, as the other DDL statements of the reference do (Bucket 'nosuch' was not found, Type with name 'NoSuchType' was not found, Cannot create the index on type 'T.nosuch' because the property does not exist are all 400).

The numeric bucket id does not crash: either the statement takes the bucket names only and says so, or it takes the ids the page documents and refuses the names it cannot resolve.

Notes

Activity

  1. added
    server
    severity:minor
    on Nov 17, 2026
  2. shaunpatterson commented on Nov 17, 2026

    @shaunpatterson
    ContributorAuthor

    One more statement of the same family, found while checking the property pages:

    statement answer
    ALTER PROPERTY T.x MIN 'abc' 500 CommandExecutionException: The MIN 'abc' of property 'T.x' cannot be read as a number of characters

    The message names the problem, so only the status is wrong, like the other CommandExecutionException cases of the issue. Measured on the same build (main 1541bf7f9f) and on arcadedata/arcadedb:26.10.1, which answers the same.

  3. added this to the 26.12.1 milestone on Nov 17, 2026
  4. added
    in progress
    on Nov 17, 2026
  5. added 6 commits that reference this issue on Nov 17, 2026
  6. self-assigned this
    on Nov 23, 2026
  7. added 2 commits that reference this issue on Nov 23, 2026
  8. added a commit that references this issue on Nov 23, 2026
  9. lvca commented on Nov 23, 2026

    @lvca
    Member

    Fixed by #12451, ships in 26.12.1.

    What was wrong: these statements were refused for a mistake in the statement itself, or for the state of the schema, but the refusal was reported as a server failure (HTTP 500). One of them, CREATE TYPE ... BUCKET <id>, did not even get that far and crashed with a NullPointerException, because only bucket names were handled.

    What changes for you:

    • CREATE DOCUMENT TYPE X BUCKET 1,2,3 works: a bucket given by its ID is attached to the new type. The bucket must exist already, and an unknown ID is refused with HTTP 400. A bucket given by its name is still created when it does not exist.
    • A bare word as a constraint value ((mandatory maybe), (regexp abc)) and a MIN or MAX that cannot be read (ALTER PROPERTY T.x MIN 'abc') answer 400 with the same message as before.
    • CREATE PROPERTY ... (mandatory true) or NOTNULL true over records that already break it answers 400 Constraint violated (MANDATORY) / (NOT_NULL), like the MIN, MAX and REGEXP refusals over stored data. The same holds for a TIMESERIES type whose stored samples break the new constraint.
    • DROP BUCKET of a bucket that belongs to a type answers 400, and the bucket keeps its records. Detach it with ALTER TYPE ... BUCKET -<bucket> or drop the type to remove it.

    Over PostgreSQL, Bolt and MongoDB these refusals now come back as client errors too, instead of internal ones. On a cluster, a follower that forwards such a statement to the leader answers its client with the same 400.


    ❤️ 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.

  10. removed
    in progress
    on Nov 23, 2026
  11. added 2 commits that reference this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserverseverity:minorsql

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions