Skip to content

fix: bind creation dates as timestamps and encode environment names - #260

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/python-client-real-responses
Nov 4, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/python-client-real-responses

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Closes #256
Closes #257

Behaviour notes

  • The API's creationDate is still a string, so the contract is unchanged, but the text a POST answers changes form.
  • A name containing / now reaches the server as %2F. The servlet stack is expected to reject that with 400 rather than the previous unmapped-route 404. Either way the caller gets an error rather than a wrong environment. This was not exercised against a running server.
  • The commented-out date check in the Python Environment model was left alone. It can be restored as a separate change now that creates answer a valid date.

Verification gaps

  • Postgres was not exercised. No Postgres server is available in the session sandbox. The regression test runs on H2 in PostgreSQL mode with a real TIMESTAMP column, so the insert is untested on the production database. A local POST /api/v1/entities against the compose stack is recommended.
  • test_setCreationDate_accepts_what_the_service_answers is a contract pin, not a regression test. The model did not change, so it passes with or without the fix. The Python side of Creating an entity or environment binds Date.toString() text to a TIMESTAMP column and answers a date no read answers #256 was confirmed by constructing Entity with the old format, which raises ValueError.

Triage / skip reasons

Test plan

  • mvn -B test: 661 tests, 0 failures, 0 errors
  • pytest (Python 3.9+): 128 passed
  • python3 -m pytest (Python 3.8): 128 passed
  • With the three fixed source files reverted, CreationDateSchemaTest errors with Cannot parse "TIMESTAMP" constant, EntityFactoryTest fails on the date format, and the six parametrized name tests fail. With the fixes restored, all pass. For two words, the failure only shows the client now encodes the space itself, since requests would otherwise have done so.
  • CI green on the PR head
  • POST /api/v1/entities and POST /api/v1/environments against real Postgres

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

…256, #257)

The entity and environment factories bound Date.toString() text to a
TIMESTAMP column and answered the same text, which no read of the row
answers and which the Python Entity model rejects. Both now bind a
timestamp and answer the format a read gives.

The Python client's get_environment_by_name interpolated a free-text
name into the URL, so "a?b" looked up "a" and "../1" fetched
environment 1. The name is now encoded as one path segment.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (head c318fba):

  • Scope: PASS. All eight files serve Creating an entity or environment binds Date.toString() text to a TIMESTAMP column and answers a date no read answers #256 or Python client's get_environment_by_name can answer a different environment for a name containing ? # or ../ #257. The two fixes are unrelated in cause and are batched because both are small defects in how the Python client meets real server values.
  • Tests-new: PASS. CreationTimestamp is package-private and is exercised through both factories by CreationDateSchemaTest. It has no direct unit test of its own.
  • Tests-fix: PASS. With EntityFactory, EnvironmentFactory and environmentService.py reverted, CreationDateSchemaTest errored twice, EntityFactoryTest failed once, and six parametrized name tests failed. All passed once restored. Two tests are weaker than that result suggests: test_setCreationDate_accepts_what_the_service_answers passes with or without the fix, and the two words case only pins that the client encodes the space itself, not a user-visible defect.
  • Sibling structure: PASS. The new test follows EnvironmentRepositorySchemaTest (an H2 DataSource built through DataSourceConfig, torn down per test).
  • Sibling renames: PASS (n/a). Nothing was renamed.
  • Docs: PASS. creationDate is an untyped string in the spec with no example, and no Markdown file or the Postman collection mentions its format, so no documentation source changes.
  • Issue resolution: PASS. The surfaces named by Creating an entity or environment binds Date.toString() text to a TIMESTAMP column and answers a date no read answers #256 and Python client's get_environment_by_name can answer a different environment for a name containing ? # or ../ #257 are all changed, and each acceptance item is covered.
  • CI: PASS. build, python-client (3.8) and python-client (3.12) are green on the head SHA. This does not cover Postgres, since the Java tests run on H2.
  • DTO boundary: PASS (n/a). No controller changed.
  • Spec alignment: PASS. The route set and types are unchanged. docs/openapi/viron-api.json is untouched.
  • Java/Python parallelism: PASS with a note. Dates are fixed at the server, so both clients benefit, and neither Java client change is needed for ? or #. The Java client's handling of / and .. in a name was not examined. Its URI template handling may not encode those the way the Python client now does.
  • Override correctness: PASS. The only @Override added is CreationTimestamp.toString, which overrides Object.toString.

Adversarial pass on the timestamp change: Timestamp.valueOf(LocalDateTime) and the text both derive from the same JVM-local value, the column has no time zone, and DateTimeFormatter output stays ASCII digits regardless of default locale. The stored value is therefore the wall-clock time Date.toString() would have carried, wherever that insert succeeded.

Remaining risk: the insert has not been run on Postgres. Binding a java.sql.Timestamp to a TIMESTAMP column is standard JDBC and no worse than binding text in any case, so this is recorded as an accepted gap and not treated as a blocker. A smoke test of both create endpoints after merge is recommended.

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 594e92e into main Nov 4, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/python-client-real-responses branch November 4, 2026 08:22
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