Files
alkhttp/tasks/adapters/review-002-js01-placeholder-check.md
T

61 lines
2.4 KiB
Markdown

---
id: review-002-js01-placeholder-check
name: Fix placeholder check skipped when input_schema has no properties (JS-01)
status: completed
depends_on: []
scope: single
risk: low
impact: component
level: implementation
tags: [adapters, review-002, from-jsonschema]
---
## Description
Review 002 JS-01 [major]. `from_jsonschema`'s eager placeholder-binding
check is skipped when `input_schema` has no `properties` key:
`spec_name_references_undeclared` (`from_jsonschema.rs:166-188`) hits
`if properties.is_empty() { return false; }` at :173-175. So:
```rust
FromJsonSchema::new(spec_with_input_schema_type_object_no_properties,
path_template = "/widgets/{id}")
```
**passes construction** — then every call fails (`{id}` unbound →
INTERNAL at forward.rs:441-446; a peer-supplied `id` key →
INVALID_INPUT). The from_openapi equivalent (`unbound_placeholders`,
from_openapi.rs:36-57) handles the empty case correctly: with no
declared properties, any placeholder is unbound. The existing test
(from_jsonschema.rs:699-724) covers only the properties-present case.
## Acceptance Criteria
- [ ] Drop the `is_empty` early return (or return `true` for
placeholders when properties are empty — same semantics as the
from_openapi path)
- [ ] Test: `FromJsonSchema::new` with a no-properties schema +
`{id}` template fails at construction with the placeholder
error; a no-properties schema with a placeholder-free template
still constructs fine
- [ ] `cargo test`, `cargo clippy --all-targets -- -D warnings`,
`cargo fmt --check` pass
## References
- docs/reviews/002-post-remediation-review.md (Part E', cluster item JS-01; Test-gap 11)
- src/adapters/from_jsonschema.rs:166-188 (the early return), :77-93 (the construction-time validation), :699-724 (the present-props test)
- src/adapters/from_openapi.rs:36-57 (the correct reference implementation)
- docs/architecture/decisions/066-from-jsonschema-as-http-adapter.md
## Notes
One-line fix + one test. Explicitly approved to fold into any commit
that is already touching from_jsonschema.rs (e.g. the wire-tests task)
if a session prefers — but if touched standalone, keep it its own
commit per the small-units convention.
## Summary
Removed the properties.is_empty() early return in spec_name_references_undeclared - placeholder templates with a properties-less input_schema now fail construction (matches from_openapi unbound_placeholders). Both acceptance branches tested.