Skip to content

chore(env): drop dead mergeJSONTopLevel + error on mixed JSON selectors#130

Merged
fentas merged 4 commits into
mainfrom
cleanup/drop-json-hybrid
Apr 7, 2026
Merged

chore(env): drop dead mergeJSONTopLevel + error on mixed JSON selectors#130
fentas merged 4 commits into
mainfrom
cleanup/drop-json-hybrid

Conversation

@fentas

@fentas fentas commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Follow-up from PR #127 review (round 7, comment about dead `filterJSONHybrid` mixed-mode merge).

What

`filterJSONHybrid`'s mixed-simple-and-complex code path called `mergeJSONTopLevel`, but no test ever exercised it and no real-world use case justified maintaining it. JSON has no comments to preserve, so the dual-path was always thin.

Changes

  • Delete `mergeJSONTopLevel` entirely (~25 lines).
  • `filterJSONHybrid` now errors out on mixed selectors with a clear message: "use either dot-paths only or JMESPath only".
  • New test `TestFilterContent_JSON_MixedSelectorsErrors` pins the error contract.

Behavior

Case Before After
Simple-only JSON gjson via `filterJSON` unchanged
Complex-only JSON JMESPath via `filterJSONJMESPath` unchanged
Mixed JSON dead code via `mergeJSONTopLevel` error

This is one of the small follow-ups mentally tracked from the #127 review loop.

🤖 Generated with Claude Code

filterJSONHybrid had a "mixed simple + complex" code path that called
mergeJSONTopLevel, but no test ever exercised it and no real-world use
case justified maintaining it. JSON has no comments to preserve, so
the historical reason for the dual-path was always thin: users either
want a clean dot-path extraction (gjson) or a full JMESPath query, not
both on the same JSON file.

Changes:
  - Delete mergeJSONTopLevel entirely (~25 lines).
  - filterJSONHybrid now errors out on mixed selectors with a clear
    message: "use either dot-paths only or JMESPath only".
  - New test TestFilterContent_JSON_MixedSelectorsErrors pins the
    error contract.

Behavior:
  - Simple-only JSON selectors: unchanged (filterJSON via gjson).
  - Complex-only JSON selectors: unchanged (filterJSONJMESPath).
  - Mixed JSON selectors: now errors instead of going through dead code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

This PR removes an untested “mixed selector” merge path for JSON selects and makes mixed simple+JMESPath selectors on JSON files fail fast with a clear error, while adding a regression test to lock the new behavior.

Changes:

  • Deleted the dead mergeJSONTopLevel helper and the mixed-mode JSON merge branch.
  • Updated filterJSONHybrid to return an explicit error when simple and complex selectors are mixed for .json.
  • Added TestFilterContent_JSON_MixedSelectorsErrors to pin the new error contract.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/env/select.go Removes JSON mixed-mode merge code and introduces an explicit error for mixed selector lists on JSON.
pkg/env/select_jmespath_test.go Adds test coverage asserting mixed selectors on JSON return an error mentioning “mixing”.

Comment thread pkg/env/select.go
Address copilot review on #130: the filterContent doc comment
advertised mixing simple+complex selectors as a general feature, but
filterJSONHybrid now intentionally rejects mixed selectors for .json
files. Update the comment so callers aren't misled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread pkg/env/select_jmespath_test.go Outdated
The previous assertion only checked for the substring "mixing",
which any unrelated JSON parse error would also satisfy. Pin the
specific guidance string the error contract promises so a future
refactor can't quietly change the wording.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread pkg/env/select.go Outdated
Comment thread pkg/env/select.go Outdated
…round 3)

Update the public-facing docs to match filterJSONHybrid's actual
behavior: JSON files reject mixed simple+complex selectors with
an explicit error. The previous wording in env-sync.mdx implied
mixed mode worked for any file format. Also drop a stale #135
follow-up reference from the source comment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@fentas fentas merged commit 61979f1 into main Apr 7, 2026
14 checks passed
@fentas fentas deleted the cleanup/drop-json-hybrid branch April 7, 2026 18:59
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.

2 participants