Fixed https://github.com/github/entitlements-app/issues/68#69
Open
trespilhas wants to merge 2 commits intomainfrom
Open
Fixed https://github.com/github/entitlements-app/issues/68#69trespilhas wants to merge 2 commits intomainfrom
trespilhas wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the entitlements text-file parser so metadata_* values are treated as free-form text (like description), preventing semicolons in metadata values from being interpreted as semicolon predicates (Fixes issue #68).
Changes:
- Update
parsed_datato bypass semicolon-predicate parsing formetadata_*keys. - Update metadata parsing spec to assert semicolons in metadata values are preserved and do not raise.
- Add a fixture containing a semicolon in a metadata value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/entitlements/data/groups/calculated/text.rb |
Bypass parsed_predicate for metadata_* keys so semicolons aren’t parsed as predicates. |
spec/unit/entitlements/data/groups/calculated/text_spec.rb |
Updates metadata tests to cover semicolons in metadata values. |
spec/unit/fixtures/ldap-config/metadata/semicolon.txt |
New fixture demonstrating metadata value containing a semicolon. |
Comments suppressed due to low confidence (1)
lib/entitlements/data/groups/calculated/text.rb:300
- This change also alters semantics for metadata values that look like semicolon predicates (e.g.
metadata_kittens = awesome; expiration = 2018-01-01): they will no longer be parsed into{key:, expiration:}and therefore won’t triggerparse_with_prefix's “additional setting(s)” error. If this is intended (per PR description), please add a spec covering this behavior so it’s explicit and protected against regressions.
if key == "description" || key.start_with?("metadata_")
result[key][operator] << { key: val }
else
result[key][operator] << parsed_predicate(val)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+297
to
300
| if key == "description" || key.start_with?("metadata_") | ||
| result[key][operator] << { key: val } | ||
| else | ||
| result[key][operator] << parsed_predicate(val) |
Comment on lines
+188
to
+189
| expect { described_class.new(filename: filename) }.not_to raise_error | ||
| subject = described_class.new(filename: filename) |
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.
Fixes #68
Problem
The text file parser treats
;as a predicate separator on all lines, includingmetadata_*lines. When a metadata value contains a semicolon (e.g.metadata_continuing_business_justification = Need access; for project work), the parser callsparsed_predicate, which raises:ArgumentError: Unparseable semicolon predicate "for project work"
Fix
Extend the existing
descriptionbypass inparsed_datato also covermetadata_prefixed keys. These are free-form text values (like descriptions) and should not have their semicolons parsed as predicates.Changes
lib/entitlements/data/groups/calculated/text.rb- Addkey.start_with?("metadata_")to the condition that bypassesparsed_predicatespec/.../text_spec.rb- Replace the test that expected an error on metadata semicolons with one that asserts no error is raised and the value is preservedspec/.../text_spec.rb- Removed outdated spec. Expirations on metadata will be treated like regular text.spec/fixtures/.../semicolon.txt- New fixture with a semicolon in a metadata value