Refactor duplicated DIFC tag parsing in WASM response handling#6748
Merged
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Refactor duplicate DIFC tag parsing in wasm_parse.go
Refactor duplicated DIFC tag parsing in WASM response handling
May 30, 2026
Collaborator
|
@copilot resolve the merge conflicts in this pull request |
Collaborator
|
@copilot resolve the merge conflicts in this pull request |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors WASM guard response parsing to centralize DIFC tag extraction from decoded JSON, ensuring secrecy/integrity labels are derived consistently for both resource and collection-item parsing paths.
Changes:
- Added
parseDIFCTagsFromAny(raw any) []difc.Tagto encapsulate[]any→[]difc.Tagconversion (string-only, non-slice →nil). - Updated
parseResourceResponseandparseCollectionLabeledDatato delegate secrecy/integrity tag parsing to the shared helper. - Added a focused unit test covering helper behavior across nil, non-slice, empty-slice, and mixed-type inputs.
Show a summary per file
| File | Description |
|---|---|
| internal/guard/wasm_parse.go | Introduces shared DIFC tag parsing helper and removes duplicated conversion logic in resource/collection parsing. |
| internal/guard/wasm_response_parse_test.go | Adds direct unit test for the new shared DIFC tag parsing helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
Contributor
Author
This was referenced May 30, 2026
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.
The WASM guard response parser duplicated the same
[]any→[]difc.Tagconversion logic across resource and collection label paths, creating multiple update points for identical DIFC parsing behavior. This change centralizes that conversion so secrecy and integrity labels are derived consistently everywhere they are parsed.Shared DIFC tag parsing
parseDIFCTagsFromAny(raw any) []difc.Tagininternal/guard/wasm_parse.go[]anynilfor non-slicesResource response parsing
parseResourceResponseCollection item label parsing
parseCollectionLabeledDataFocused parser coverage