Skip to content

Fixed https://github.com/github/entitlements-app/issues/68#69

Open
trespilhas wants to merge 2 commits intomainfrom
trespilhas/issues/68
Open

Fixed https://github.com/github/entitlements-app/issues/68#69
trespilhas wants to merge 2 commits intomainfrom
trespilhas/issues/68

Conversation

@trespilhas
Copy link

Fixes #68

Problem

The text file parser treats ; as a predicate separator on all lines, including metadata_* lines. When a metadata value contains a semicolon (e.g. metadata_continuing_business_justification = Need access; for project work), the parser calls parsed_predicate, which raises:

ArgumentError: Unparseable semicolon predicate "for project work"

Fix

Extend the existing description bypass in parsed_data to also cover metadata_ 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 - Add key.start_with?("metadata_") to the condition that bypasses parsed_predicate
  • spec/.../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 preserved
  • spec/.../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

Copilot AI review requested due to automatic review settings March 13, 2026 18:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_data to bypass semicolon-predicate parsing for metadata_* 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 trigger parse_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)
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.

metadata_ lines with semicolons raise ArgumentError: Unparseable semicolon predicate

2 participants