Skip to content

fix(har): parse pubspec.yaml with a YAML library so trailing comments are ignored - #350

Open
BlueLabelscotch wants to merge 1 commit into
mainfrom
worktree-fix-har-dart-pubspec-yaml
Open

BlueLabelscotch wants to merge 1 commit into
mainfrom
worktree-fix-har-dart-pubspec-yaml

Conversation

@BlueLabelscotch

Copy link
Copy Markdown
Collaborator

Fixes #333

Problem

parsePubspecNameVersion matched name:/version: lines by hand, so a trailing YAML comment (version: 1.0.0 # bump me) ended up in the parsed value.

Change

  • Unmarshal pubspec.yaml into a small struct with go.yaml.in/yaml/v3 (already a dependency of this module), matching hc, which uses a YAML parser here.
  • Remove the line-based extractPubspecField.
  • Missing keys now return empty strings and fall through to the existing must contain non-empty 'name' and 'version' check, as in hc. Malformed YAML returns failed to parse pubspec.yaml: ....
  • Add a table test covering trailing comments, quoted values, nested name/version keys, a missing key, and malformed YAML.

Module-only change (modules/har); no new dependencies.

Testing

go test ./pkg/har/ -run TestParsePubspecNameVersion in modules/har

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

Review completed with 0 suggestions.

Reviewed commit: fcc912d

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.

HAR: Dart trailing YAML comments end up in the parsed version

1 participant