Skip to content

Enforce lowercase alphanumeric/underscore naming across all metadata APIs - #403

Merged
em3s merged 12 commits into
mainfrom
feat/disallow-hyphen-in-v3-names
Jul 11, 2026
Merged

em3s merged 12 commits into
mainfrom
feat/disallow-hyphen-in-v3-names

Conversation

@em3s

@em3s em3s commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enforces a uniform naming policy — ^[a-z][a-z0-9_]{0,63}$ — across all Actionbase metadata create paths: V3 (database, table, alias) and V2 (service, label, alias, storage). Names containing hyphens or uppercase letters are rejected with 400 Bad Request on create. Read, update, and delete paths are unaffected. Note: creating a new table/alias under a legacy-named parent database is rejected, since the parent name is validated on create — intentional, as it also stops new resources accreting under non-conforming databases.

Why this naming policy

Two constraints that apply simultaneously drove the choice of ^[a-z][a-z0-9_]{0,63}$:

  1. URL path safety — Names appear directly in HTTP path segments. Uppercase causes case-sensitivity issues across clients, proxies, and load balancers. Hyphens are technically URL-safe but create ambiguity with path separators in some routing layers.
  2. HBase naming constraints — Names map directly to HBase table and namespace identifiers. Allowing names that pass HTTP validation but fail HBase validation produces confusing runtime errors deep in the stack.

The intersection of these two constraint sets is: lowercase letters, digits, and underscores only, starting with a letter, max 64 characters.

Changes

Single source of truth

  • core/Constants.Name — PATTERN, MESSAGE, COMMENT_MAX_LENGTH, COMMENT_SIZE_MESSAGE, STORAGE_URI_PATTERN, STORAGE_URI_MESSAGE as const val
  • server/util/NameValidator — shared validator used by all controllers; throws ResponseStatusException(400) on mismatch
  • V3NameValidator — now delegates to NameValidator

V3 — create paths

  • DatabaseController, TableController, AliasController: name validation on POST only
  • TableCreateRequest, AliasCreateRequest, AliasUpdateRequest: @Pattern and @Size annotations reference Constants.Name
  • TableCreateRequest.storage: datastore URI regex updated to disallow uppercase
  • Bug fix: AliasUpdateRequest.table was still using the old regex (allowed hyphens/uppercase)

V2 — create paths only

  • ServiceController, ServiceLabelController, ServiceAliasController, StorageController: path variable validated on POST only
  • ServiceLabelController.copy: new target name validated; existing source names are not

HBase

  • DatastoreHBaseService.createTable: table name qualifier validated via NameValidator

Tests

  • All hyphenated fixture names migrated to underscore style
  • Explicit hyphen returns 400 and uppercase returns 400 test cases added per resource type
  • AliasControllerTest: update-path validation tests for table field added
  • V3NameValidatorTest: my-db, MyDB, A moved to invalid cases

How to Test

Create with a hyphenated name → 400:

curl -X POST .../graph/v3/databases -d '{"database":"my-db","comment":""}' → 400
curl -X POST .../graph/v2/service/my-service -d '{...}' → 400

Read an existing legacy resource → 200:

curl .../graph/v3/databases/my-db → 200 (if it exists)

⚠️ Breaking Change — Deploy Prerequisites

This PR is a breaking change for any code that creates metadata resources.

Before deploying, all clients and pipelines that automatically create metadata (services, labels, aliases, databases, tables, storages) must be audited and updated to ensure they only submit names matching ^[a-z][a-z0-9_]{0,63}$. Any pipeline submitting names with hyphens or uppercase will receive 400 after this lands.

Existing legacy-named resources remain readable, updatable, and deletable. Only creation is restricted — including new child resources under a legacy-named parent, which now return 400.

Reviewer Notes

  • Update/delete path variables are intentionally excluded from validation — existing legacy-named resources stay readable/updatable/deletable. Create paths do validate the parent name, so new children cannot be added under a legacy-named parent.
  • Constants.Name is in the core module, which is already a dependency of both engine and server. No new module dependencies introduced.
  • PR Block v2 Storage creation #399 (remove v2 Storage metadata) is based on this branch; StorageController changes here will be superseded by its deletion in Block v2 Storage creation #399.

Checklist

  • Small, focused PR
  • Self-reviewed the diff
  • Tests updated and passing locally
  • Build and lint checks pass
  • Breaking change documented — clients/pipelines creating resources with hyphenated or uppercase names must be updated before deployment

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Sonnet 4.6

…erscore

V3 database, table, and alias names now only accept lowercase letters,
digits, and underscores (hyphens and uppercase letters are rejected).
This aligns with HBase table naming conventions and avoids ambiguity
between names used as identifiers in multiple systems.

- V3NameValidator: pattern updated to ^[a-z][a-z0-9_]{0,63}$
- TableCreateRequest: @pattern annotation updated to match
- All E2E and controller tests migrated to underscore-style names

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels Jul 9, 2026
@em3s em3s changed the title feat(server): restrict V3 API names to lowercase alphanumeric and underscore Restrict V3 API names to lowercase alphanumeric and underscore Jul 9, 2026
@em3s em3s changed the title Restrict V3 API names to lowercase alphanumeric and underscore Restrict V3 resource names to lowercase alphanumeric and underscore Jul 9, 2026
GET/PUT/DELETE no longer reject existing resources with legacy names.
Name validation is enforced only on POST (create) requests, so
hyphenated/uppercase resources created before this change remain
accessible.

Also fixes AliasCreateRequest.alias and .table patterns to match the
new policy (lowercase alphanumeric/underscore only).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 10, 2026
em3s and others added 3 commits July 10, 2026 13:27
Add Constants.Name with PATTERN, MESSAGE, MAX_LENGTH as the single
source of truth for the ^[a-z][a-z0-9_]{0,63}$ naming rule.

V3NameValidator and all @pattern annotations in request classes
(AliasCreateRequest, AliasUpdateRequest, TableCreateRequest) now
reference Constants.Name instead of inline literals. TableCreateRequest
storage URL regex also updated to disallow uppercase in namespace/table
segments.

Fix missing validation on AliasUpdateRequest.table (was still allowing
hyphens and uppercase). Add update-path validation tests to
AliasControllerTest.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Add NameValidator (server/util) as the shared enforcement point for
Constants.Name.PATTERN. V3NameValidator now delegates to it.

Apply NameValidator.validate() to all V2 create/update path variables:
- ServiceController: service name
- ServiceLabelController: service + label names, copy target
- ServiceAliasController: service + alias names
- StorageController: storage name

Read/delete paths are unaffected — existing legacy names remain accessible.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 10, 2026
Validate the table name qualifier against Constants.Name.PATTERN
in DatastoreHBaseService.createTable. Existing table operations
(get/update/enable/disable/delete) are unaffected.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@em3s em3s changed the title Restrict V3 resource names to lowercase alphanumeric and underscore Enforce lowercase alphanumeric/underscore naming across all metadata APIs Jul 10, 2026
Move the datastore:// URI regex into Constants.Name.STORAGE_URI_PATTERN
and STORAGE_URI_MESSAGE. TableCreateRequest.storage @pattern now
references the constant. DatastoreUri exposes URI_PATTERN from the same
source.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@em3s em3s self-assigned this Jul 10, 2026
em3s and others added 5 commits July 10, 2026 17:00
V2 update path variables accept any name so existing resources with
legacy names remain accessible — consistent with V3 policy.

copy target (a new name being created) is still validated.

Also fix Constants.Name.STORAGE_URI_PATTERN to require each segment to
start with a lowercase letter, matching Name.PATTERN. Remove dead
DatastoreUri.URI_PATTERN.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Add COMMENT_MAX_LENGTH and COMMENT_SIZE_MESSAGE to Constants.Name.
All @SiZe annotations on comment fields now reference these constants.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@em3s

em3s commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Deploy prerequisites

Before upgrading, confirm no existing resource violates the new policy — run via the Actionbase CLI:

actionbase -e "doctor names"

Expected: No violations found. Resolve every violation before the upgrade.

Two things doctor names won't catch — audit these separately:

  1. Legacy-named parent databases block new children. Create paths validate the parent name, so even a policy-conforming table/alias cannot be created under a hyphenated/uppercase database. If such a database must keep receiving new tables, rename it — otherwise its children stay frozen.
  2. /graph/v2/admin/hbase/... createTable is not covered by this PR. That admin endpoint writes directly to HBase without name validation. Any tooling creating tables through it must enforce the policy on its own.

Existing legacy-named resources remain readable, updatable, and deletable — only creation is restricted.

@em3s

em3s commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Merging

@em3s
em3s merged commit d38db83 into main Jul 11, 2026
2 checks passed
@em3s
em3s deleted the feat/disallow-hyphen-in-v3-names branch July 11, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant