Open
Conversation
Previously, when the same group name was defined in multiple child files, each definition was added separately, causing duplicate key errors. This change: - Merges group members when the same group name appears in multiple files - Deduplicates members during merge - Tracks all source files in comments (from/and format) - Sorts groups by source so same-source groups appear together - Dedupes consecutive identical comments to reduce noise Fixes duplicate group names causing parse errors
Previously, when the same group name was defined in multiple child files, each definition was added separately, causing duplicate key errors. This change: - Merges group members when the same group name appears in multiple files - Deduplicates members during merge - Tracks all source files in comments (from/and format) - Sorts groups by source so same-source groups appear together - Dedupes consecutive identical comments to reduce noise Fixes duplicate group names causing parse errors
There was a problem hiding this comment.
Pull request overview
Adds support for merging duplicate object keys (notably groups) across multiple child ACL files to avoid duplicate-key errors and to produce a single combined definition with deduplicated members and consolidated source comments.
Changes:
- Update
handleObject()to merge array-valued members when the same key appears multiple times, deduplicating merged array entries. - Add post-merge formatting utilities to sort object members by source comments and dedupe consecutive identical comments.
- Add tests covering group merging and array deduplication behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| main.go | Implements array-merge + dedup for duplicate object keys; adds comment merge, source-based sorting, and comment dedupe utilities. |
| main_test.go | Adds tests for group merging across files/children and for mergeArraysWithDedup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When merging duplicate keys in nested objects (e.g., autoApprovers.routes), the existing member may have no `from` comment. Now initializes with `from parentPath` before appending `and childPath`, and avoids adding duplicate paths.
When merging arrays with mergeArraysWithDedup, the new array lost any
comments attached to the original array node. Now copies Before, Line,
and End comments from the existing array to the merged result.
Example of preserved comments:
"group:name": [ // This comment is now preserved
"user@example.com"
] // This comment is now preserved too
Replace ignored errors from jwcc.Parse with explicit error assertions to prevent nil dereferences if input becomes invalid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, when the same group name was defined in multiple child files, each definition was added separately, causing duplicate key errors (#34).
This change:
Groups and other ACL sections handled with
handleObject()that are defined across multiple files now combine into a single definition. Following the example from #34 :{ "groups": { // from `companies/company-1/groups.hujson` // and `companies/company-2/groups.hujson` "group:group-name": [ "member-1@company.com", "member-2@company.com", "member-3@company.com", "member-4@company.com", ] } }Tested this in my org and works as expected.