Skip to content

fix: keep credentials out of filter and sort allowlists; read numeric keys canonically - #612

Merged
dmealing merged 10 commits into
mainfrom
fm/mo-filter-credential-allowlist
Nov 20, 2026
Merged

dmealing merged 10 commits into
mainfrom
fm/mo-filter-credential-allowlist

Conversation

@dmealing

@dmealing dmealing commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Generated filter and sort allowlists exclude credential fields (a field declaring view.password), including a shared column of a single-table (TPH) hierarchy. The filter type, OpenAPI parameters and agent UI page leave them out too. A request naming one gets the existing 400 invalid_filter_field or invalid_sort. The change lands in the TypeScript, C#, Java, Kotlin and Python generators. In Java, Kotlin and C# the sort allowlist previously listed every scalar field, so routes for models with a credential change: regenerate. Covered by the shared secret-fields/ api-contract scenarios and a test per port.
  • The TypeScript, Java and Python ObjectManagers, and the TypeScript HTTP mounts, read a numeric key (integer, long, decimal, double, float) from text only in canonical decimal form. Forms such as 0x1, 1e0, +1, whitespace, leading zeros and negative zero are refused with each runtime's existing bad-key error: InvalidKeyError / 400 invalid_id in TypeScript, IllegalArgumentException for Java ref ids, ValueError in Python. The check walks characters, with no regex. String and uuid keys are unchanged.
  • CHANGELOG: the grid-proof line count in the 1.1.0 entry is corrected from 1,823 to 1,826 to match docs/features/metadata-driven-runtime.md.
Validation

Risk Assessment

✅ Low: The credential allowlist and canonical-key changes trace correctly in every port. The round-6 TPH sibling-credential scenario is wired into all five generated-lane harnesses, and I found no source-backed defect.

Testing

Baseline scripts/ci-local.sh --affected --strict-toolchains already passed at the target commit and covered broad regression. Driven live: (1) a generated TypeScript API against a real Postgres testcontainer refuses filter and sort on a credential with invalid_filter_field / invalid_sort, and the TPH sibling-credential rule holds on base and subtype routes, 4 passing; (2) a real TypeScript ObjectManager mounted on Fastify answers 400 invalid_id for 0x1, 1e0, +1, whitespace, trailing dot, leading zero, negative zero and an unsafe integer, and 200 for canonical 1 and 9007199254740991. The Python key-text pytest file passed (44), but in-process only, so it is not counted as live. Java, Kotlin, Python and C# credential allowlists were not driven live here. The CHANGELOG line count is documentation-only with no runtime surface. Overall: the three live scenarios pass. Evidence logs are in the evidence directory.

  • Live validation: ✅ go - 3 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Live: generated TS filter and sort on a credential (view.password marked @filterable/@Sortable) is refused with invalid_filter_field / invalid_sort, real Postgres testcontainer over HTTP ✅ pass live ts-secret-fields-live.log (bun test -t filter-sort-refuses-credential, 2 layouts)
Live: TPH sibling-credential shared column is refused on base and subtype filter/sort routes ✅ pass live ts-secret-fields-live.log (bun test -t tph-sibling-credential, 2 layouts)
Live: TS ObjectManager Fastify mount refuses non-canonical numeric key text (0x1, 1e0, +1, whitespace, 01, -0, 1., unsafe 9007199254740993) with 400 invalid_id; canonical 1 and 9007199254740991 pass ✅ pass live ts-canonical-key-live.log (script run against real runtime-ts ObjectManager and Fastify mountCrudRoutes, in-memory driver, synthetic ids)
Python ObjectManager refuses non-canonical numeric key text ⏸️ untested no Only the in-process pytest file ran; no live Python product surface was driven, so it is not counted as live. Intent says a test per runtime; the pytest file covers that.
Java, Kotlin, Python and C# filter/sort allowlists exclude credentials live ⏸️ untested no Not driven live in this turn; the per-port api-contract and codegen tests are covered by the configured affected lanes at baseline. Driving them would need the Java, Kotlin, Python and C# generated ha…
CHANGELOG grid-proof line count corrected from 1,823 to 1,826 ⏸️ untested no Documentation-only change with no runtime surface; no-surface, so nothing to drive live.
Evidence: TS generated secret-fields filter/sort and TPH credential refusal, live Postgres testcontainer (bun test, 4 pass)
bun test v1.3.14 (0d9b296a)

 4 pass
 6 filtered out
 0 fail
Ran 4 tests across 1 file. [6.13s]
Evidence: TS canonical key text refused on real Fastify ObjectManager mount (400 invalid_id per non-canonical id)
{"id":"1","status":200,"body":"{\"id\":1,\"title\":\"One\"}"}
{"id":"0x1","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"1e0","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"+1","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":" 1","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"1 ","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"01","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"-0","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"1.","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"9007199254740993","status":400,"body":"{\"error\":\"invalid_id\"}"}
{"id":"9007199254740991","status":200,"body":"{\"id\":9007199254740991,\"title\":\"Max\"}"}
{"id":"abc","status":400,"body":"{\"error\":\"invalid_id\"}"}
Evidence: Python ObjectManager numeric key-text pytest (44 passed, in-process)
............................................                             [100%]
=============================== warnings summary ===============================
<site-packages>/_pytest/config/__init__.py:1397
  <site-packages>/_pytest/config/__init__.py:1397: PytestConfigWarning: Unknown config option: cache_dir
  
    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_integer_key_is_read[1-1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_integer_key_is_read[0-0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_integer_key_is_read[-7--7]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_integer_key_is_read[123456789012-123456789012]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[0x1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[1e0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[+1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[ 1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[1 ]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[01]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[-0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[1.]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[1_0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[\u0663]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[0b1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[0o1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[1.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[-]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[00]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_integer_key_is_refused[\n1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_decimal_key_is_read[1.5-1.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_decimal_key_is_read[0-0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_decimal_key_is_read[-7.25--7.25]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_canonical_decimal_key_is_read[0.5-0.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[0x1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1e0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1.]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[+1.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[nan]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[inf]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[-inf]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[-0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[-0.0]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[01.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[ 1.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1.5 ]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1_0.5]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1.5e1]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_non_canonical_decimal_key_is_refused[1.\u0663]
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_double_key_beyond_float_range_is_refused
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_string_key_is_untouched
PASSED tests/runtime/test_object_manager_numeric_key_text.py::test_native_numbers_pass_through
44 passed, 1 warning in 0.33s

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ✅ Resolved (the pipeline resolved the conflict with main in the rebase step) docs/CONFORMANCE.md - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - findings resolved; 1 info (currency-key note) not changed
  • ✅ Resolved (the author decided to fix it; the TypeScript readers now refuse an integer key that is not a safe integer and any non-finite result, with InvalidKeyError / undefined; Python refuses the infinity case; each site has a test) server/typescript/packages/runtime-ts/src/canonical-key.ts:47 - Canonical text is accepted without a range check, so two different canonical key texts can still name one row in TypeScript. isCanonicalInteger and isCanonicalDecimal accept any digit string, and coercePkValue (object-manager.ts:587-597), parseId and coerceIdForColumn (drizzle-fastify/util.ts) then call Number(). For a field.long key, 9007199254740992 and 9007199254740993 both become 9007199254740992, which is the same class of problem the change set out to close. A canonical string of more than 308 digits becomes Infinity for a double or float key. Java's KeyText.coerce refuses both cases: it uses Long.parseLong and rejects an infinite double or float. Python's int() is exact. Smallest fix: make the TS readers refuse an integer that Number.isSafeInteger rejects, or a non-finite result, with the same InvalidKeyError or undefined. This adds a rule beyond canonical form, so it needs the author's sign-off. The sibling sites are object-manager.ts:591 and :595, util.ts parseId, and util.ts coerceIdForColumn (number branch). Python's float and double branch at object_manager.py _coerce_key_value has the same infinity case.
  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
  • ✅ Resolved (fixed in the same run: the ejected runtime copies in both examples were re-synced and gained canonical-key.ts and errors.ts) examples/showcase/codegen/runtime/drizzle-fastify/util.ts:7 - The committed ejected runtime copies in examples/showcase and examples/advanced-modeling are broken and stale. drizzle-fastify/util.ts:7 imports ../canonical-key.js, drizzle-fastify/route-error-handler.ts:35 imports ../errors.js, and constraint-errors.ts:30 imports ./errors.js. codegen/runtime/ holds neither canonical-key.ts nor errors.ts in either example (ls shows only constraint-errors, decimal-wire, drizzle-fastify/, duration-wire, route-errors, sql-dialect, timestamp-wire and wire-format). Those imports cannot resolve. meta eject copies the transitive closure of the package's relative imports, so a fresh eject would add both files. These copies were edited by hand or partially regenerated. util.ts:64 in both examples also still reads Number.isFinite(Number(raw)), while the package has !Number.isNaN(Number(raw)) after the fix round (de75062). So the copies are not verbatim, which defeats the 'byte comparison against the package' contract described in cli/src/lib/runtime-eject.ts. Fix: re-run the example regeneration (scripts/regen-showcase.ts, or meta eject routes entity per example) so both examples get canonical-key.ts, errors.ts and the current util.ts. Sibling sites: examples/advanced-modeling/codegen/runtime/drizzle-fastify/util.ts:7, .../drizzle-fastify/route-error-handler.ts:35, .../constraint-errors.ts:30, and examples/showcase/codegen/runtime/drizzle-fastify/route-error-handler.ts:35 and .../constraint-errors.ts:30.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
  • ✅ Resolved (the author decided to fix it; isCanonicalDecimal now also requires a safe integer for integer-shaped text, with tests for parseId, coerceIdForColumn, rawIdLiteral and a decimal key) server/typescript/packages/runtime-ts/src/canonical-key.ts:50 - Round-1 finding review-1 (user chose to fix) is only half closed. Fix round 2 (de75062) added Number.isSafeInteger to isCanonicalInteger and Number.isFinite to isCanonicalDecimal. But isCanonicalDecimal still accepts integer-shaped text without a safe-integer check. parseId(&#39;9007199254740993&#39;) and coerceIdForColumn({dataType:&#39;number&#39;}, &#39;9007199254740993&#39;) both pass isCanonicalDecimal (finite) and return Number(raw) = 9007199254740992. So two different canonical id texts (...992, ...993) still name one row on every HTTP mount that reads a numeric column id (drizzle-fastify/index.ts:288,380,429; hono/index.ts:281,347,384; mount-read-only.ts fastify:316 and hono:278; mount-m2m.ts:102,113), and rawIdLiteral emits the rounded literal on raw-SQL views. This is the class the change set out to close. The new test only covers the unsafe-integer case through isCanonicalInteger; its isCanonicalDecimal cases cover the infinite case only. Smallest fix: in isCanonicalDecimal, when the text has no ., also require isCanonicalInteger(text). Sibling: coercePkValue DECIMAL_SUBTYPES branch (object-manager.ts:594-596) takes the same isCanonicalDecimal for field.decimal, so an integer-valued decimal key past 2^53 also rounds. Add test cases for coerceIdForColumn/parseId/rawIdLiteral with 9007199254740993.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
  • ✅ Resolved (fixed: the loaded root is passed at that call site and in the test-generators copy, with a test) server/typescript/packages/codegen-ts/src/templates/entity-file.ts:231 - renderFilterType(entity) is the one call site that still omits the loaded root. The other four sites (reference/entity.ts:148, projection-decl.ts:222, value-object-file.ts:69 and :99) now pass ctx.loadedRoot. Without it credentialFieldNames sees the entity alone. So when a TPH sibling subtype marks a shared column as a view.password, the client Filter type for this entity still offers that column as filterable and sortable. The server allowlist built on the lines just above (renderFilterAllowlist(entity, undefined, ctx)) refuses it with 400. The CHANGELOG says the client filter type leaves credentials out. renderEntityFile is a live path: the entity-file generator (generators/entity-file.ts:48) and the read-view branch of reference/entity.ts:130 both call it. This is a client-type inconsistency only; the server still refuses the request, so no leak. Same omission in the test-generators copy: server/typescript/packages/test-generators/src/templates/entity-file.ts:231. Fix: pass ctx.loadedRoot as the third argument in both.

🔧 Fix applied.
3 issues (1 warning, 2 infos) still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
  • ✅ Resolved (the author decided to fix it; Java, Kotlin, Python and C# now build a hierarchy-wide credential set, so the column is on no allowlist of the base or any subtype, in either declaration order) server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringFilterAllowlistGenerator.java:144 - The credential exclusion on the filter allowlists is per-field only in Java, Kotlin, Python and C#. TypeScript also excludes a column that a sibling subtype of the same single-table (TPH) hierarchy marks as a credential (credentialFieldNames, filter-shared.ts, with a test). In the other four ports a TPH base allowlist is the union of base and subtype columns, deduplicated by name (out.putIfAbsent). Take two subtypes that both declare token. AThing has it as a plain @filterable column. BThing has it as view.password. The generator skips BThing's token as a credential but keeps AThing's. token therefore stays on the base allowlist, and GET /things?filter[token][like]=a% probes the shared column that holds BThing's secret. The intent says the allowlists are 'built without credentials in every port', and the TS side already treats this model as in scope. Same invariant, other sites: KotlinFilterAllowlistGenerator.kt:~201 (putIfAbsent), filter_allowlist_generator.py:~223 (the add closure; the outcome depends on declaration order), FilterAllowlistGenerator.cs:~152, and the sort-field loops at SpringControllerGenerator.java:~1162 and KotlinSpringControllerGenerator.kt:~931. The remedy extends the per-port change to a hierarchy-wide credential set. Whether the other ports should match TS here, or the TS hierarchy rule should be narrowed, is the author's decision.
  • ℹ️ CHANGELOG.md:176 - The CHANGELOG entry for canonical key text does not mention a behavior the TS fix rounds added. TypeScript now also refuses an integer key that is not a safe integer (beyond ±2^53, isCanonicalInteger and isCanonicalDecimal for integer-shaped text) and a non-finite decimal key. Java uses Long.parseLong and accepts up to Long.MAX_VALUE. A TS field.long key from 2^53 to 2^63-1 used to round silently to a different row. It is now InvalidKeyError (HTTP 400 invalid_id). Add one sentence so the cross-runtime difference is recorded.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
  • ✅ Resolved (the author decided to fix it; the shared TPH sibling-credential scenario was added to secret-fields and runs in the generated lane of all five ports) fixtures/api-contract-conformance/secret-fields/scenarios/filter-sort-refuses-credential.yaml:1 - Recorded round-5 decision required ONE shared scenario in fixtures/api-contract-conformance/secret-fields for the TPH sibling-credential rule: a TPH base with two subtypes that both declare token, one plain @filterable/@sortable and one view.password. A filter and a sort on token must answer 400 invalid_filter_field / invalid_sort on the base route and on the plain subtype's route. Commit e3a5819 adds no fixture or scenario. It adds only per-port codegen unit tests, which are string checks on generated output. docs/CONFORMANCE.md counts and the secret-fields README are unchanged, though CHANGELOG now says the rule holds 'in every port'. No cross-port HTTP corpus gates the hierarchy-wide rule. The corpus has a single Account model and each port's harness hard-codes it (e.g. InMemoryAccountRepositorySource.java, GeneratedSecretFieldsControllerHarness.kt, generated_secret_fields_app.py, SecretFieldsGeneratedServerFactory.cs, api-contract-secret-fields-generated-server.ts), so the scenario needs a second model and harness work in five ports. The remedy extends harness machinery, so the author or user must confirm the scope or accept the unit tests as sufficient. The generator logic itself traces correct: base and subtype allowlists in Java, Kotlin, Python and C# drop token in both declaration orders.

🔧 Fix applied.
1 info still open:

  • ℹ️ server/python/src/metaobjects/runtime/object_manager.py:1140 - Cross-runtime gap on field.currency keys. Java's KeyText.isNumeric includes CurrencyField and refuses non-canonical text such as 01 or 1. TypeScript's INTEGER_SUBTYPES and Python's _KEY_INT_SUBTYPES leave currency out, so currency key text still goes through the old lenient path (Python's _INT_TEXT, which allows whitespace, and TS's raw string). A currency primary key is unlikely, so this is low impact. If it matters, add FIELD_SUBTYPE_CURRENCY to the integer set in TS (object-manager.ts:579) and Python (object_manager.py:1141).
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Live: generated TS filter and sort on a credential (view.password marked @filterable/@Sortable) is refused with invalid_filter_field / invalid_sort, real Postgres testcontainer over HTTP ✅ pass live ts-secret-fields-live.log (bun test -t filter-sort-refuses-credential, 2 layouts)
Live: TPH sibling-credential shared column is refused on base and subtype filter/sort routes ✅ pass live ts-secret-fields-live.log (bun test -t tph-sibling-credential, 2 layouts)
Live: TS ObjectManager Fastify mount refuses non-canonical numeric key text (0x1, 1e0, +1, whitespace, 01, -0, 1., unsafe 9007199254740993) with 400 invalid_id; canonical 1 and 9007199254740991 pass ✅ pass live ts-canonical-key-live.log (script run against real runtime-ts ObjectManager and Fastify mountCrudRoutes, in-memory driver, synthetic ids)
Python ObjectManager refuses non-canonical numeric key text ⏸️ untested no Only the in-process pytest file ran; no live Python product surface was driven, so it is not counted as live. Intent says a test per runtime; the pytest file covers that.
Java, Kotlin, Python and C# filter/sort allowlists exclude credentials live ⏸️ untested no Not driven live in this turn; the per-port api-contract and codegen tests are covered by the configured affected lanes at baseline. Driving them would need the Java, Kotlin, Python and C# generated ha…
CHANGELOG grid-proof line count corrected from 1,823 to 1,826 ⏸️ untested no Documentation-only change with no runtime surface; no-surface, so nothing to drive live.
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun test test/api-contract-secret-fields.test.ts -t &#34;filter-sort-refuses-credential|tph-sibling-credential|sibling&#34; in server/typescript/packages/integration-tests (4 pass, 0 fail; 2 layouts x 2 scenarios; one Postgres testcontainer per scenario via Docker)
  • Live script (in $DEV_SCRATCH, removed after): real runtime-ts ObjectManager + in-memory driver + Fastify mountCrudRoutes, GET /posts/<id> for 1, 0x1, 1e0, +1, ' 1', '1 ', 01, -0, 1., 9007199254740993, 9007199254740991, abc
  • python3 -m pytest -p no:cacheprovider tests/runtime/test_object_manager_numeric_key_text.py in server/python (44 passed; in-process unit-level, not live)
  • Checked worktree clean after testing (no artifacts left in worktree); no containers started by this run remained (other sessions' containers untouched)
🔧 **Document** - 1 issue found → auto-fixed (2) ✅
  • ℹ️ CHANGELOG.md:177 - The ObjectManager key-text rule (Java/Python/TS findById, update, delete and load take only canonical decimal text, pass the decimal spelling) is recorded only in the CHANGELOG release note. No durable owner doc states it. Candidate owners: spec/wire-format.md or docs/features/api-contract.md. Out of scope for this doc-repair pass, which is limited to stale facts, so left as one follow-up.

🔧 Fix applied.
3 infos still open:

  • ℹ️ docs/features/api-contract.md:221 - Round-1 user decision (docs-1) was not yet applied in the target commit. Added the ObjectManager key-text rule to the malformed-id row: TypeScript, Java and Python ObjectManagers read a numeric key passed as text to findById, update, delete and load by canonical decimal form only, so the caller passes the decimal spelling; a string or uuid key is untouched. Verified the rule against server/typescript/packages/runtime-ts/src/canonical-key.ts. Resolved, so no open item remains here.
  • ℹ️ docs/features/api-contract.md:689 - The credentials paragraph said the allowlist is built without a credential but did not state the single-table rule. Added one clause: on a TPH hierarchy a column one subtype marks as a credential is on no allowlist of the base or any subtype. Verified against the C# FilterAllowlistGenerator and RoutesGenerator, which call TphPlanBuilder.HierarchyCredentialNames. Resolved.
  • ℹ️ docs/features/own-your-codegen.md:390 - Pre-existing gap, not caused by this change: the routes eject row lists the runtime-ts files copied into codegen/runtime/ but omits decimal-wire.ts, duration-wire.ts, sql-dialect.ts and wire-format.ts, which drizzle-fastify imports transitively. This change added canonical-key.ts and errors.ts to the row. A full closure list is a wider edit to an ownership table, so I left the rest as is.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…numeric keys only from canonical decimal text

A field that declares a view.password is now left out of the generated filter and sort
allowlists in every port, so a client cannot probe a credential by filtering or sorting on it;
an explicit request answers the existing invalid_filter_field / invalid_sort 400. Covered by one
shared api-contract scenario and a test per port.

The TypeScript, Java and Python ObjectManagers now read a numeric primary key from text only in
canonical decimal form (no 0x1, 1e0, +1, whitespace, leading zero or negative zero), with each
runtime's existing bad-key error. Also corrects the grid-proof line count in the CHANGELOG.
@dmealing
dmealing merged commit ae8dddf into main Nov 20, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-filter-credential-allowlist branch November 20, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant