Skip to content

A REGEXP declared on a non-text property is accepted and then refuses every write, while MIN and MAX on the same property are refused at declaration time #9808

Closed

Description

@ruispereira

Summary

CREATE PROPERTY T.n LONG (regexp '[A-Z]+') and ALTER PROPERTY T.n REGEXP '[A-Z]+' are both accepted. A pattern is matched against the value's string form, so a pattern written for text refuses every value of a numeric, boolean, date or binary property. The declaration is written to the schema, reports success, and survives a reopen, leaving a property no value can be written through. The type does not have to be empty for this to pass unnoticed: the existing-records scan only looks at what is already stored, and a type that holds no record of that property has nothing to refuse.

MIN and MAX are already guarded on exactly this ground: LocalProperty.setMin/setMax call checkBound, which refuses a bound the type cannot use (Maximum value not applicable for type BOOLEAN) or cannot read (The MAX 'zz' of property 'R1.n' cannot be read as LONG). REGEXP has no equivalent. The Cypher re-type path refuses to carry a REGEXP onto a non-STRING type for the same reason ("a pattern describes text: on any other type it is matched against the value's string form, which is not what it was written for"), so the same declaration is refused through one door and accepted through another.

Where

  • engine/src/main/java/com/arcadedb/schema/LocalProperty.java:308 - setRegexp assigns and saves, with no readability check:
  @Override
  public Property setRegexp(final String regexp) {
    checkForSchemaMutation();
    final boolean changed = !Objects.equals(this.regexp, regexp);
    if (changed) {
      this.regexp = regexp;
      owner.getSchema().getEmbedded().saveConfiguration();
    }
    return this;
  }

against setMax/setMin at LocalProperty.java:249/:261, which call checkBound at :283.

  • engine/src/main/java/com/arcadedb/schema/DocumentType.java:156 routes the CREATE PROPERTY ... (regexp ...) and JSON declaration path to the same unguarded setter.
  • engine/src/main/java/com/arcadedb/query/sql/parser/AlterPropertyStatement.java:136 is the ALTER PROPERTY ... REGEXP arm; its requireStoredValuesWithin helper calls DocumentValidator.requireReadableBound for MIN and MAX only, then scans the stored records, which is a no-op on a property no record carries.

Repro

CREATE VERTEX TYPE R1;
CREATE PROPERTY R1.n LONG (regexp '[A-Z]+');
INSERT INTO R1 SET n = 1;

Observed:

  CREATE PROPERTY R1.n LONG (regexp '[A-Z]+')      : OK
  R1.n JSON                                        : {"type":"LONG","regexp":"[A-Z]+","custom":{}}
  INSERT INTO R1 SET n = 1                         : EX:ValidationException: The property 'R1.n' does not match the regular expression '[A-Z]+'. Field value is: 1, record: @R1[n=1]
  CREATE (x:R1 {n: 1})                             : EX:CommandExecutionException
  for comparison, MAX is already refused           : EX:CommandExecutionException: The MAX 'zz' of property 'R1.n' cannot be read as LONG
  and on a BOOLEAN                                 : EX:CommandExecutionException: Cannot set attribute on property max 3: Maximum value not applicable for type BOOLEAN

ALTER PROPERTY R1.n REGEXP '[A-Z]+' on an already declared LONG behaves the same way. After closing and reopening the database:

  reopened R1.n : {"type":"LONG","regexp":"[A-Z]+","custom":{}}
  INSERT        : EX:ValidationException: The property 'R1.n' does not match the regular expression '[A-Z]+'. Field value is: 1, record: @R1[n=1]

Suggested fix

Give LocalProperty.setRegexp the guard setMin/setMax already have, next to checkBound so the two stay in step: refuse a REGEXP on a property whose values are not text, naming the property and its type, the way the Cypher re-type path already names it. As checkBound does, only warn rather than refuse when the schema is being read from file (isReadingFromFile), so a database written before the rule still opens and ALTER PROPERTY ... REGEXP null remains the remedy.

If a pattern over the string form of a numeric value is considered a feature worth keeping ('[0-9]{3}' on a LONG), the narrower rule is to refuse only a pattern that no value of the new type can satisfy, but the simple type check matches what the engine already decided for this exact question in the re-type path and is the one that keeps the two doors consistent.

Scope / confidence

High confidence, reproduced on main at db832c29e7 through the embedded API with the output above. Engine-wide: any SQL, JSON or Java API declaration path reaches setRegexp. The fix is one guard in one setter plus its isReadingFromFile escape; the risk is refusing a pattern an existing database legitimately relies on, which the read-from-file warning path covers.

Activity

  1. added
    engine
    severity:minor
    on Oct 11, 2026
  2. added
    in progress
    on Oct 12, 2026
  3. self-assigned this
    on Oct 12, 2026
  4. added this to the 26.11.1 milestone on Oct 12, 2026
  5. added a commit that references this issue on Oct 12, 2026
  6. lvca commented on Oct 12, 2026

    @lvca
    Member

    Fixed in #9820 (26.11.1).

    A REGEXP is now refused when it is declared (CREATE PROPERTY, ALTER PROPERTY, the Java API, a JSON schema) if no value of the property could ever pass it:

    • on a type whose values have no text form a pattern can describe: BINARY, LIST, MAP, EMBEDDED, LINK, ARRAY_OF_*
    • on a BOOLEAN, a pattern that matches neither true nor false
    • an invalid pattern

    A pattern on a number or a date stays allowed, because it is useful there (e.g. '[0-9]{5}' on a LONG). We chose not to refuse every non-STRING type, as suggested: that would have removed this working feature. A database that already holds such a declaration still opens, with a warning; ALTER PROPERTY ... REGEXP null removes it.


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

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

Metadata

Metadata

Assignees

Labels

bugengineseverity:minorsql

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions