Repository navigation
fix(types): strengthen dispatch struct contracts for Dialyzer - #76
Conversation
yordis
commented
Apr 15, 2026
- Makes more of the dispatch pipeline visible to static analysis so contract drift is caught earlier without adding more runtime checks
- Aligns the typed dispatch surface with real usage, including named application atoms and the middleware pipeline struct shape
PR SummaryLow Risk Overview Strengthens the dispatch surface for Dialyzer by fully specifying Reviewed by Cursor Bugbot for commit 08ee8a9. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (4)
WalkthroughThis PR tightens and expands type specifications: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/commanded/commands/dispatcher.ex`:
- Around line 14-33: The Payload type declares many fields as required (non-nil)
but defstruct allows them to be nil; add an `@enforce_keys` attribute for the
non-nil fields so the struct cannot be created without them. Update the module
that defines %__MODULE__{} (the Payload struct) to include something like
`@enforce_keys` [:application, :command, :command_uuid, :consistency,
:handler_module, :handler_function, :aggregate_module, :identity, :timeout,
:lifespan, :metadata, :returning, :middleware] (omitting fields intentionally
allowed to be nil such as :causation_id, :correlation_id,
:handler_before_execute, :identity_prefix, :retry_attempts), and keep the
existing defstruct unchanged so construction matches the `@type` t/0 guarantees.
In `@lib/commanded/middleware/pipeline.ex`:
- Around line 43-56: The declared type t for module Pipeline lists fields
(application, command, command_uuid, consistency, identity, metadata, etc.) as
non-nil but defstruct provides no defaults so those become nil when not
supplied; either add `@enforce_keys` [:application, :command, :command_uuid,
:consistency, :identity, :metadata] above defstruct to require those fields at
construction (ensuring callers pass them) or update the `@type` t to allow nil for
those specific fields; modify the Pipeline module’s defstruct/@type accordingly
and keep symbols application, command, command_uuid, consistency, identity,
metadata, `@type` t, and defstruct consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4bf7723f-8bd9-4601-ad93-9fa07fe25e77
📒 Files selected for processing (4)
lib/commanded/commands/dispatcher.exlib/commanded/commands/router.exlib/commanded/middleware/middleware.exlib/commanded/middleware/pipeline.ex
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
0f8c570 to
08ee8a9
Compare