Skip to content

fix: bound names to their column and document the rejections - #265

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/bound-name-length
Nov 7, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/bound-name-length

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • A name over 255 characters is now answered 400 with name: size must be between 0 and 255 on every create and rename route, instead of reaching the VARCHAR(255) column and being reported as a 500 on a rename or a generic 400 on a create. @Size(max = 255) was added to all five request bodies and to the debug route's environmentName.
  • The spec states the bound as maxLength, documents the 400 on GET /api/v1/environments/name/{name}, names the rejected name in the debug route's 400, and no longer claims ErrorResponse accompanies the bodiless 401 and 403.
  • OpenApiSpecDriftTest now counts @NotBlank as validated input, which is how the undocumented 400 went unnoticed, and has a new check that the request bodies' @Size bound matches the spec's maxLength.
  • docs/MVP.md records the rule.

Closes #263
Closes #264

Client impact

Neither client changes. The bound is enforced by the service, and both clients already raise on a 400: the Python client through raise_for_status, the Java client through its general catch. Names of 256 or more characters could never be stored, so no previously working request is refused, with one edge: @Size counts UTF-16 code units while the column counts characters, so a name made mostly of characters outside the Basic Multilingual Plane can be refused below 255 characters.

Test plan

  • mvn -B test: 680 tests, 0 failures
  • pytest: 128 passed (client untouched)
  • New over-long-name tests and the two drift guards failed on the unfixed code and pass with the fix
  • The spec parses as JSON, and all 37 Postman routes match the spec's 37
  • Smoke test on Postgres: PATCH a 256-character name and confirm 400, then a 255-character name and confirm 200

Verification gap

The Java tests run on H2 and mocks, and the sandbox cannot start Postgres. The 500 was reproduced by making the repository report the failed write, not by a real over-long write on Postgres. The fix does not depend on Postgres, since validation runs before the database is reached.

The over-long tests cannot fail silently: their rename stubs answer 500 if validation is bypassed. The two blank-name tests are characterization, because that validation already existed.

Scope

The diff touches 12 files against a soft ceiling of about 10: five are the same one-line annotation, and the production change is under 20 lines.

Merge hold

This PR changes docs/openapi/viron-api.json, which is on the dev loop's do-not-auto-merge list, so it is left open for human review.

Issues not picked up

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

A name longer than the VARCHAR(255) column that stores it reached the
database, where the failed write was flattened to false: 500 on a rename,
a generic 400 on a create. The request bodies and the debug path variable
now carry @SiZe(max = 255), so it is answered 400 naming the field, and
the spec states the bound as maxLength.

GET /environments/name/{name} could answer 400 without the spec saying
so, because the drift guard ignored @notblank. The guard now counts it,
the route documents the answer, and the ErrorResponse description agrees
with docs/MVP.md about the bodiless 401 and 403.

Closes #263
Closes #264

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric, scored against head 99913be with CI green on build, python-client (3.8) and python-client (3.12). This review is the session's own, not an independent one.

Findings fixed before this review: both blank-name tests first used a literal %20, which MockMvc double-encoded so that Spring Security's firewall answered the request and the handler was never reached. They now use URI template variables. The docs/MVP.md note also first landed inside the DTO checklist and was moved below it.

Non-blocking notes:

  • src/test/java/preponderous/viron/OpenApiSpecDriftTest.java — the new guard covers request bodies only, so the maxLength on the debug route's EnvironmentNameParam is unguarded. The route is pinned by DebugControllerTest.
  • src/main/java/preponderous/viron/dto/CreateEntityRequest.java — @Size counts UTF-16 code units while the column counts characters, so the bound is slightly stricter for characters outside the Basic Multilingual Plane. It errs on the side of refusing, and the PR body states it.
  • src/main/java/preponderous/viron/factories/EnvironmentFactory.java:62 — outside this diff: numGrids, gridSize, numRows and numColumns have no upper bound, so one request can run a very long transaction. A limit is a product decision and is not addressed here.

The dev loop's merge hold applies because the diff touches docs/openapi/viron-api.json. Human review and the Postgres smoke test in the PR body are the remaining steps.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 98e2565 into main Nov 7, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/bound-name-length branch November 7, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant