Skip to content

refactor(api): dispatchInputs struct in DispatchAction (#165)#205

Merged
PaulDotterer merged 1 commit into
mainfrom
refactor/165-dispatch-inputs-struct
May 10, 2026
Merged

refactor(api): dispatchInputs struct in DispatchAction (#165)#205
PaulDotterer merged 1 commit into
mainfrom
refactor/165-dispatch-inputs-struct

Conversation

@PaulDotterer

@PaulDotterer PaulDotterer commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #165 (audit F032 + F048).

Groups the five loose locals `DispatchAction` extracted from
either ActionSource branch (`actionType`, `desiredState`,
`params`, `timeoutSeconds`, `actionID`) into a single
`dispatchInputs` struct. Downstream sites (eventData / sign /
taskqueue payload / log) now read from `inputs.X` — the "where
did this value come from" question has one answer.

The struct's field comments document each value's source-branch
provenance (stored vs inline), folding F032's `var params any`
clarification into the right home — the field comment instead of
a free-floating inline comment that travels with neither caller.

`signature` + `paramsCanonical` stay separate per the acceptance
criteria — they're computed downstream by the re-sign step, not
extracted from either branch.

No behaviour change; all DispatchAction tests stay green (~80s
incl. testcontainer setup).

Test plan

  • `go test ./internal/api/ -run TestDispatchAction` — pass
  • CI green

Summary by CodeRabbit

  • Refactor
    • Improved internal code structure for action dispatching logic to enhance maintainability and consistency in how action parameters and timeouts are processed.

Review Change Stack

Closes #165 (audit F032 + F048).

Groups the five loose locals DispatchAction extracted from either
ActionSource branch (actionType, desiredState, params, timeoutSeconds,
actionID) into a single dispatchInputs struct. Downstream sites
(eventData / sign / taskqueue payload / log) now read from
inputs.X — the "where did this value come from" question has one
answer.

The struct's field comments document each value's source-branch
provenance (stored vs inline), folding F032's "var params any"
clarification into the right home — the field comment instead of
a free-floating inline comment that travels with neither caller.

signature + paramsCanonical stay separate per the acceptance
criteria — they're computed downstream by the re-sign step, not
extracted from either branch.

No behaviour change; all DispatchAction tests stay green (~80s
incl. testcontainer setup).
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45f05abb-98d0-41c3-a2b9-97d3a5a2679b

📥 Commits

Reviewing files that changed from the base of the PR and between 86b1df3 and d20212c.

📒 Files selected for processing (1)
  • internal/api/action_dispatch.go

📝 Walkthrough

Walkthrough

DispatchAction was refactored to consolidate five loose derived fields into an internal dispatchInputs struct. Both stored-action and inline-action branches populate the struct, and all downstream code—event construction, signing, task dispatch, and logging—now reads from this unified container.

Changes

Input Consolidation Refactor

Layer / File(s) Summary
Data Structure Definition
internal/api/action_dispatch.go
Internal dispatchInputs struct introduced with fields for actionType, desiredState, params, timeoutSeconds, and optional actionID. Single inputs variable declared.
Stored-Action Branch
internal/api/action_dispatch.go
Stored-action branch populates inputs by parsing action.Params into map[string]any (falling back to raw string), and assigns timeoutSeconds and actionID.
Inline-Action Branch
internal/api/action_dispatch.go
Inline-action branch populates inputs by serializing params via serializeProtoParams(extractActionParamsMsg(...)), assigning actionType, desiredState, and timeoutSeconds (defaulting to 300 when omitted or ≤0).
Event Data & Params Marshaling
internal/api/action_dispatch.go
Event data construction reads from inputs fields and conditionally includes action_id when inputs.actionID is non-nil. Params are marshaled from inputs.params into paramsJSON.
Signing & Dispatch
internal/api/action_dispatch.go
Signer invocation uses inputs.actionType. Asynq task payload is built from consolidated inputs fields and marshaled paramsJSON. Action-dispatched log uses inputs.actionType.String().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

A rabbit bundled five loose things with care,
Into a struct, grouped beyond compare—
inputs.this and inputs.that,
No more scattered like a hat,
Consolidation, neat and fair! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introduction of a dispatchInputs struct to consolidate five separate local variables in DispatchAction.
Linked Issues check ✅ Passed All acceptance criteria from issue #165 are met: dispatchInputs struct introduced, all references rewritten to inputs.X, signature/paramsCanonical kept separate, no behavior change, and build/lint green per test plan.
Out of Scope Changes check ✅ Passed All changes in internal/api/action_dispatch.go are directly related to the refactoring objective; no extraneous modifications or out-of-scope changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/165-dispatch-inputs-struct

Comment @coderabbitai help to get the list of available commands and usage tips.

@PaulDotterer PaulDotterer merged commit 759baa5 into main May 10, 2026
5 checks passed
@PaulDotterer PaulDotterer deleted the refactor/165-dispatch-inputs-struct branch May 10, 2026 23:18
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.

audit F032+F048: dispatchInputs struct in DispatchAction (and var params any clarification)

1 participant