Skip to content

fix: dependabot config equality must be key-order-independent - #37

Merged
avrabe merged 1 commit into
mainfrom
fix/dependabot-deep-equal
May 1, 2026
Merged

fix: dependabot config equality must be key-order-independent#37
avrabe merged 1 commit into
mainfrom
fix/dependabot-deep-equal

Conversation

@avrabe

@avrabe avrabe commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Fixes Bug #27 from docs/agent-fleet/bugs.md (wave-1 QA bug-hunter).

JSON.stringify(a) === JSON.stringify(b) was order-sensitive; identical configs in different key orders compared unequal → unnecessary writes / PRs. Tiny inline canonicalize helper sorts keys deeply before comparing. No new dependency.

  • 809 tests pass (+3)
  • eslint clean

🤖 Generated with Claude Code

## Why
`src/dependabot.js:108` used `JSON.stringify(currentConfig) === JSON.stringify(targetConfig)`
to compare the existing dependabot.yml against the target. yaml.load preserves
source key order; identical configs serialised in different key orders
compared *unequal* → unnecessary writes (and unnecessary PRs when
`change_strategy.use_pull_requests: true`).

## What
Tiny inline `canonicalize(value)` helper that recursively sorts object keys;
arrays preserved in order; primitives unchanged. Comparison becomes
`JSON.stringify(canonicalize(a)) === JSON.stringify(canonicalize(b))`.

No new dependency. Helper stays inside `src/dependabot.js`.

## Source
Wave-1 QA bug-hunter flagged this as Bug #27 in `docs/agent-fleet/bugs.md`.

## Test plan
- [x] 809 tests pass (was 806; +3 covering: identical configs in different
      key order compare equal; genuinely different configs unequal; arrays
      with different element order unequal — intentional, arrays are ordered)
- [x] eslint clean

## Risk & rollout
- Risk: low. Pure equality refinement; only affects a "skip work when
  unchanged" branch. Worst case is one extra write per repo if the new
  comparator misses an equality (it doesn't).
- Rollout: self-update on merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe
avrabe merged commit 5a42370 into main May 1, 2026
5 checks passed
@avrabe
avrabe deleted the fix/dependabot-deep-equal branch May 1, 2026 07:14
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.

1 participant