Skip to content

test: regression guard for devcontainer JSON trailing-data parse error#855

Merged
Bryan-Roe merged 3 commits into
mainfrom
copilot/fix-build-and-test-failure
Jul 11, 2026
Merged

test: regression guard for devcontainer JSON trailing-data parse error#855
Bryan-Roe merged 3 commits into
mainfrom
copilot/fix-build-and-test-failure

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

The build-and-test devcontainer CI job failed because .devcontainer/devcontainer-lock.json had a stray } after the root closing brace, causing @devcontainers/cli to throw SyntaxError: Unexpected non-whitespace character after JSON at position 2143 and abort the build.

The structural fix (removing the stray brace) landed in PR #852. This PR adds a regression test to catch the same class of corruption before it reaches CI.

Changes

  • tests/test_devcontainer_config.py — four @pytest.mark.unit tests:
    • test_devcontainer_json_is_valid_json / test_devcontainer_lock_json_is_valid_json — basic json.loads() validity
    • test_devcontainer_json_no_trailing_data / test_devcontainer_lock_json_no_trailing_data — uses JSONDecoder.raw_decode() to explicitly verify no non-whitespace content follows the root object, with a descriptive failure message showing the offset and trailing bytes
decoder = json.JSONDecoder()
_parsed, end_index = decoder.raw_decode(content)
trailing = content[end_index:]
assert trailing.strip() == "", (
    f"{path.name} has trailing non-whitespace data after the root JSON object "
    f"(at offset {end_index}): {trailing!r}"
)

Copilot AI requested review from Copilot and removed request for Copilot July 11, 2026 04:43

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@Bryan-Roe Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository and had to close this PR. The error I am seeing is:

no `copilot-setup-steps` job found in your `copilot-setup-steps.yml` workflow file. Please ensure you have a single job named `copilot-setup-steps`. For more details, see https://gh.io/copilot/actions-setup-steps

Once you or someone with the necessary access fixes the problem, please unassign and then reassign issue #0 to me and I'll retry. Thanks!

Add tests/test_devcontainer_config.py to verify that both
.devcontainer/devcontainer.json and .devcontainer/devcontainer-lock.json
are valid JSON with no trailing data.

Root cause of build-and-test CI failure (job 86511118286): a stray `  }`
appended after the root object in devcontainer-lock.json caused
@devcontainers/cli to throw:
  SyntaxError: Unexpected non-whitespace character after JSON at position 2143
aborting the devcontainer build step entirely.

The structural fix (removing the stray brace) was applied in commit 6b470e3.
These tests prevent regression.
Copilot AI requested review from Copilot and removed request for Copilot July 11, 2026 04:48
Use json.JSONDecoder().raw_decode() in the trailing-data tests so that
the end position of the JSON value is explicitly checked, rather than
relying on json.loads() implicitly. This makes the test intent clear
and produces a descriptive failure message showing exactly what trailing
characters were found and at which offset.
Copilot AI requested review from Copilot and removed request for Copilot July 11, 2026 04:49
Copilot AI changed the title [WIP] Fix failing GitHub Actions job build-and-test test: regression guard for devcontainer JSON trailing-data parse error Jul 11, 2026
Copilot AI requested a review from Bryan-Roe July 11, 2026 04:50
@Bryan-Roe Bryan-Roe marked this pull request as ready for review July 11, 2026 05:41
Copilot AI review requested due to automatic review settings July 11, 2026 05:41

@sourcery-ai sourcery-ai 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.

Sorry @Bryan-Roe, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@Bryan-Roe Thanks for sending me some feedback. Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository. The error I am seeing is:

no `copilot-setup-steps` job found in your `copilot-setup-steps.yml` workflow file. Please ensure you have a single job named `copilot-setup-steps`. For more details, see https://gh.io/copilot/actions-setup-steps

Once you or someone with the necessary access fixes the problem, please let me know in a comment and I'll try again. Thanks!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Bryan-Roe Bryan-Roe merged commit 05ca7a7 into main Jul 11, 2026
6 of 11 checks passed
@Bryan-Roe Bryan-Roe deleted the copilot/fix-build-and-test-failure branch July 11, 2026 05:41

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

Adds regression guards against malformed devcontainer JSON and trailing data.

Changes:

  • Validates both devcontainer configuration files as JSON.
  • Detects non-whitespace content after the root object.

"""
decoder = json.JSONDecoder()
try:
_parsed, end_index = decoder.raw_decode(content)
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.

3 participants