Accept a null module configuration - #2
Conversation
The module's configuration slot arrives as a serde_json::Value whose default is null, not the empty object. The previous #[serde(default)] attribute only covers missing fields, not a null document, so a host that supplies no configuration would cause a deserialization error. A hand-written Deserialize implementation now wraps the wire format in Option<Wire>, turning null into the default configuration and preserving the existing field-level defaults for the empty object. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformat the assertion in the null-configuration test to keep the method chain on a single line, improving readability without changing any behaviour. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesModuleConfig handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Null module configuration now starts the module with its existing empty defaults instead of failing initialization, while object configurations retain their prior behavior. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
How this change flows2 changed behaviours across 4 relationships. 5 surrounding behaviours are shown (60 graph nodes walked). 48 further behaviours left out to keep the diagram readable. flowchart LR
n0["ModuleConfig<br/>changed"]:::changed
n1["...at_cannot_open_its_store_fails_to_come_up<br/>changed"]:::changed
n2["json"]:::impacted
n3["service_at"]:::impacted
n4["ok"]:::impacted
n5["call"]:::impacted
n6["catalog"]:::impacted
n1 -->|uses| n0
n3 -->|uses| n0
n4 -->|calls| n5
n6 -->|calls| n2
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Green: changed behaviour. Grey: surrounding behaviour. Arrows name the call, use, implementation, or test relationship. Orange: has findings. Red: has a finding that blocks the merge. |
The v0.3.0 release built and published all sixteen platform bundles, and
TinyBus's own module host loaded the artifact — but the release workflow's final
step,
verify_github_release, refused it withmodule initialization failed.The cause
The loader's configuration slot is a
serde_json::Value, and a host thatconfigures nothing leaves it at its default — which is
null, not{}.ModuleConfigcarried#[serde(default)], which fills in absent fields butdoes not accept a whole document of the wrong type, so decoding
nullfailedand
setupreturned before it could serve anything.The unit test that was supposed to cover this decoded
"{}". The empty objectis what the documentation called an absent configuration;
nullis what theloader actually sends. So the module refused to load for exactly the host that
asked nothing of it, and said so in a message that names nothing useful.
The fix
ModuleConfignow has a hand-writtenDeserializethat decodes throughOption<Wire>, mappingnullonto the default. The field handling is stillderived, on a private wire struct, rather than restated.
Behavior changes
A module loaded with
nullconfiguration now comes up instead of failing. Noother decoding changes:
{}and a populated object behave exactly as before.Tests
Three, covering the decode, the service built from it, and the whole
setuppath a loader takes:a_null_configuration_decodes_to_a_working_defaulta_service_builds_from_a_null_configurationa_module_loaded_with_no_configuration_comes_upThe last one is the release verifier's scenario minus the download, so this
cannot regress into a release again without the suite saying so first.
Verified against the real artifact:
verify_github_releasereproduces thefailure against the published
v0.3.0bundle, which was built before this fix.Validation
cargo fmt --all -- --check— cleancargo clippy --all-targets --all-features -- -D warnings— cleancargo test --all-features— 657 passed, 0 failedcargo doc --no-deps --all-featureswith-D warnings— clean.github/scripts/check-file-coverage.sh 90— passesSummary by CodeRabbit
Bug Fixes
null, empty objects, and omitted fields gracefully by applying default settings.Tests