generator validation requires manual sid field, contradicting Rust struct emitter (which auto-injects it) #85
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_rpc#85
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
crates/generator/src/generator.rs::validate_root_objectrejects any root object that does not explicitly declare asidfield in the schema:But the Rust struct emitter (
crates/generator/src/rust/rust_struct.rs:368-389) auto-injectssid: SmartId,created_at: u64, andupdated_at: u64for every root object — and silently skips any schema-declared field with those names:The parser (
crates/oschema/src/parser.rs:655-661) detects root-object-ness from either asidfield or a[rootobject]comment marker — so the[rootobject]marker should be sufficient.Three pieces of code in disagreement:
[rootobject]marker → root object;sidfield also accepted as markersidfield REQUIRED — fails otherwisesid/created_at/updated_at; ignores any schema declarationsThe validator is the odd one out. Result: authors are forced to write a misleading
sid: strline (which the emitter ignores) just to get past validation. That line then turns into stale guidance in hero_skills#275 (the skill says root objects MUST have asid: strfield — which is only true because of this validator, not because the generated code needs it).Fix
Drop the
must have a 'sid' fieldcheck. Root-object-ness is determined by the[rootobject]marker. Thesid(andcreated_at,updated_at) fields are an implementation detail of code generation, not the schema.Keep:
must have at least one user-defined field(still useful).Drop:
must have a 'sid' field.Acceptance
types_generated.rsstill haspub sid: SmartId,pub created_at: u64,pub updated_at: u64onThing(auto-injected, unchanged).sid: strstill build (no regression).Refs
sid: strfield" rule honestly.Branch pushed:
issue-85-rootobj-sid-validation. Diff is one file:crates/generator/src/generator.rs— drop themust have a 'sid' fieldcheck invalidate_root_object; replace the test that pinned that wrong behavior with one that pins the new correct behavior.All 125 generator tests pass. Used by hero_service#1 — that branch’s Cargo.toml temporarily pins hero_rpc to this branch.
ServiceDefinitionto name + description + interfaces #1sid-field requirement on root objects (#85) #88sid-field requirement on root objects (#85) #88