Repository navigation
fix(dispatch): an empty role list is honored in dispatch - #7659
rh-hemartin wants to merge 1 commit into
Conversation
Fixed a bug in which an empty list of roles in .fullsend/config.yaml `roles: []` or `roles:` allowed any role to be dispatched. This contradicted the code behavior at `ConfigRoles()`. Now empty slice (`roles: []`) or empty value (`roles:`) prevents dispatching, while no `roles` key on the config.yaml dispatches everything. Signed-off-by: Hector Martinez <hemartin@redhat.com>
PR Summary by QodoHonor empty role lists during workflow dispatch
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
|
🤖 Finished Review · ✅ Success · Started 10:01 AM UTC · Completed 10:21 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $4.35 |
Code Review by Qodo
1. Empty role lists still dispatch
|
| HAS_ROLES="$(yq '. | has("roles")' .fullsend/config.yaml 2>/dev/null)" | ||
| if [[ "$HAS_ROLES" = "false" ]]; then | ||
| echo "::notice::No roles key on config.yaml, dispatching $STAGE_ROLE..." | ||
| exit 0 | ||
| else | ||
| echo "::notice::config.yaml has roles, checking if $STAGE_ROLE is allowed..." | ||
| fi | ||
|
|
||
| ROLES=$(yq '.roles[] // []' .fullsend/config.yaml 2>/dev/null || echo "") |
There was a problem hiding this comment.
3. Users cannot verify empty-role behavior 📘 Rule violation ⚙ Maintainability
docs/reference/config-reference.md describes replacement and inheritance for roles but does not state that an explicitly empty value blocks dispatch or that an omitted key permits every role. The new HAS_ROLES branch changes this user-facing configuration behavior, yet the PR updates neither the required configuration reference nor a related guide.
Agent Prompt
## Issue description
The dispatch behavior of omitted and explicitly empty `roles` configuration is user-facing, but the canonical configuration reference does not describe the distinction introduced by this change.
## Fix Focus Areas
- .github/workflows/reusable-dispatch.yml[543-551]
- docs/reference/config-reference.md[144-153]
- docs/guides/infrastructure/layered-config-reference.md[279-283]
## Recommended Fix
Update the configuration reference to state the purpose, valid values, omission default, and dispatch effect of `roles: []` and `roles:`. Reconcile the layered-config guide so its examples clearly distinguish configuration inheritance from final dispatch authorization.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Risk Assessment: elevated (3/5) DetailsElevated risk: small diff but modifies a protected-path CI dispatch permission gate with zero test coverage, and review found the fix likely does not close the gate for all input shapes it claims to handle. |
ReviewFindingsHigh
Medium
Low
Next steps:
|
| fi | ||
|
|
||
| ROLES=$(yq '.roles[] // []' .fullsend/config.yaml 2>/dev/null || echo "") | ||
| if [[ -n "$ROLES" ]] && ! echo "$ROLES" | grep -Fqx "$STAGE_ROLE"; then |
There was a problem hiding this comment.
[high] logic-error
After the new has("roles") check correctly lets an absent roles key dispatch everything, the membership test is still [[ -n "$ROLES" ]] && ! echo "$ROLES" | grep -Fqx "$STAGE_ROLE", with ROLES=$(yq '.roles[] // []' .fullsend/config.yaml 2>/dev/null || echo ""). That retained -n conjunct is the original fail-open pattern (issue #6915 / the #653→#655 production incident): any code path that leaves $ROLES empty skips the deny branch and dispatch proceeds. yq could not be executed in this review's sandbox (no network access), so this is reasoned from documented jq/yq splat-and-alternative-operator (//) semantics rather than confirmed by execution. Two shapes the PR explicitly claims to fix are affected: (1) roles: (YAML null) — .roles[] on a null node is expected to error before // [] can apply; the error is discarded by 2>/dev/null and || echo "" yields ROLES="", so [[ -n "$ROLES" ]] is false and dispatch proceeds — contradicting the PR body's claim that an empty value (roles:) prevents dispatching. (2) roles: [] (explicit empty array) — unverified either way: if yq's // fires on a zero-output splat the way jq's does, it emits the literal [] and the skip path fires correctly (by accident, since [] won't match a real role); if yq applies // per-node instead, the empty splat produces no output at all, ROLES="", and the array case fail-opens too. Do not treat the empty-array case as confirmed fixed.
Suggested fix: Once has("roles") is true, fail closed on an empty or unparseable role list instead of falling through. Drop the // [] sentinel and the [[ -n "$ROLES" ]] && conjunct, e.g.: ROLES=$(yq '.roles[]' .fullsend/config.yaml 2>/dev/null) || { echo "::error::Failed to parse roles from config.yaml — refusing dispatch"; exit 1; } then if ! echo "$ROLES" | grep -Fqx "$STAGE_ROLE"; then (retain the fullsend/retro/prioritize compat branch). This makes roles: [] and roles: (null) both produce an empty $ROLES that fails the grep and skips dispatch, and makes a yq parse failure fail closed. Add fixtures asserting all three shapes (absent / [] / null) plus a populated list before merging — this is a permission gate and the exact class of bug that caused the #653→#655 incident.
| echo "::notice::config.yaml has roles, checking if $STAGE_ROLE is allowed..." | ||
| fi | ||
|
|
||
| ROLES=$(yq '.roles[] // []' .fullsend/config.yaml 2>/dev/null || echo "") |
There was a problem hiding this comment.
[medium] missing-test
This is a security-relevant CI dispatch permission gate whose correct behavior now depends on subtle yq/YAML-shape distinctions (key absent vs roles: [] vs roles: null vs a non-empty list). The PR's own "Testing" checklist leaves "Tests added/updated for new or modified logic" unchecked, and there is no existing test harness in the repo exercising this bash-in-workflow logic (the Go-level ConfigRoles() unit test — "empty slice replaces parent (no roles)" in internal/config/defaults_test.go — covers only the Go config layer, not this bash/yq gate). Issue #6915's triage comment explicitly requested fixtures asserting: all stages skip when roles is explicitly empty, dispatch proceeds when the key is unset, and dispatch restricts to the listed role otherwise — checked against both workflow files. Without such tests, the fail-open regression identified above (the roles: null case) would not have been caught.
Suggested fix: Add fixtures/assertions covering roles absent / roles: [] / roles: (null) / roles: ["coder"], ideally by extracting the bash gating logic into a small testable script or a fullsend CLI subcommand backed by the already-tested ConfigRoles(), rather than leaving it as untested inline YAML bash.
| esac | ||
| ROLES=$(yq '.roles[]' .fullsend/config.yaml 2>/dev/null || echo "") | ||
|
|
||
| HAS_ROLES="$(yq '. | has("roles")' .fullsend/config.yaml 2>/dev/null)" |
There was a problem hiding this comment.
[low] design-coherence
Issue #6915's triage comment noted that internal/config/interfaces.go's ConfigRoles() already implements the correct nil-vs-empty-list distinction with unit test coverage, and that the bash/yq dispatch gate reimplementing similar logic separately is "likely how the two implementations diverged" in the first place. This PR adds another separate yq-based reimplementation (has("roles") + .roles[] // []) rather than consolidating on the existing tested Go logic. This preserves the semantic-drift risk the triage comment warned about, though it is not a blocking concern for this fix.
Suggested fix: Consider a fast-follow that routes the dispatch gate through the already-tested ConfigRoles() Go logic (e.g. a small fullsend config check-role subcommand), so the bash gate and Go config semantics cannot diverge again.
| echo "::notice::No roles key on config.yaml, dispatching $STAGE_ROLE..." | ||
| exit 0 | ||
| else | ||
| echo "::notice::config.yaml has roles, checking if $STAGE_ROLE is allowed..." |
There was a problem hiding this comment.
[low] workflow-conventions
The new else branch emits an intermediate progress ::notice:: ("config.yaml has roles, checking if $STAGE_ROLE is allowed...") that only records an in-progress state, unlike the other ::notice:: annotations in this file, which record terminal decisions (dispatch allowed/skipped) or fallback paths. This adds a UI annotation to every run where .fullsend/config.yaml has a roles key, which is more verbose than the surrounding convention.
Suggested fix: Replace the intermediate ::notice:: with a plain echo (or drop it) if progress logging is desired, reserving ::notice:: for terminal decisions as elsewhere in this file.
waynesun09
left a comment
There was a problem hiding this comment.
One finding from a review sweep, posted inline.
| esac | ||
| ROLES=$(yq '.roles[]' .fullsend/config.yaml 2>/dev/null || echo "") | ||
|
|
||
| HAS_ROLES="$(yq '. | has("roles")' .fullsend/config.yaml 2>/dev/null)" |
There was a problem hiding this comment.
[MEDIUM] roles: (null) blocks all dispatch in the workflow but inherits the parent roles in Go's ConfigRoles()
I ran this gate with yq v4.47.2:
| config | has("roles") |
.roles[] // [] |
result |
|---|---|---|---|
| key absent | false | n/a | dispatches |
roles: (null) |
true | [] (literal string) |
every stage skipped=true |
roles: [] |
true | [] (literal string) |
every stage skipped=true |
roles: [coder] |
true | coder |
only coder dispatches |
So roles: and roles: [] both fail closed here. The -n "$ROLES" guard is true because $ROLES holds the literal [], and grep then misses the stage role.
On the Go side, the per-repo config declares Roles *[]string yaml:"roles,omitempty" (internal/config/config.go) and decodes it with gopkg.in/yaml.v3. yaml.v3 decodes a YAML null into a nil pointer. ConfigRoles() (internal/config/interfaces.go) then takes the "nil (key omitted) falls through to parent" branch. For the same roles: input, the workflow blocks every stage and Go inherits the parent role list. That contradicts the PR description's claim that this change aligns the workflow with ConfigRoles().
Suggestion: Choose one meaning for roles: (null) and use it in both places:
- Make the gate match Go by treating null as omitted. For example, dispatch everything when
yq '.roles | type'is!!null. - Or change the Go decoding so a key that is present but null becomes a non-nil empty slice. Document that in
docs/reference/config-reference.md.
Either way, update the PR description to state which semantic roles: has.
|
Deprecated in favor or removing the step completely after talking with the team. |
|
🤖 Finished Retro · ✅ Success · Started 7:17 AM UTC · Completed 7:27 AM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.97 |
|
PR #7659 (fullsend-ai/fullsend) was a human-authored fix for issue #6915 ( Proposals filed |
Summary
Fixed a bug in which an empty list (
roles: []orroles:) of roles in .fullsend/config.yaml allowed any role to be dispatched. This contradicted the code behavior atConfigRoles().Now empty slice (
roles: []) or empty value (roles:) prevents dispatching, while noroleskey on the config.yaml dispatches everything.Related Issue
Closes #6915
Changes
Testing
make lintpasses (stage changes first, then run)Checklist
!for breaking changes)