Skip to content

fix: Nickel strings stay literal; a manifest lookup error is not an absent manifest - #303

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/nickel-escape-and-manifest-lookup
Nov 14, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
fix/nickel-escape-and-manifest-lookup

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

This follows up the two CodeRabbit findings on #302, which landed after #302 merged. I checked both against nickel 1.18.0 and Rust std before fixing them.

1. Nickel string escaping (src/report/formatter.rs)

nickel_escape_string used JSON quoting, which is wrong for Nickel in two ways:

Input Old output nickel export result
/tmp/%{true} "/tmp/%{true}" "/tmp/true": interpolated
a\u{1f}b "a\u001fb" invalid escape sequence
a\u{8}b "a\bb" invalid escape sequence

The escaper now writes:

  • \% for every % (Nickel reads it back as %);
  • \", \\, \n, \r and \t;
  • \u{XX} for any other control character.

The manifest export (src/a2ml) and the assault-report writer share this escaper, so both are fixed.

2. Manifest lookup (src/a2ml/mod.rs)

Manifest::default_path and load_if_exists used Path::exists(). That turns every metadata error (a self-referential symlink, a permission error) into false, so the CLI quietly fell back to the defaults. Both now use try_exists():

  • only a definite absence gives the defaults;
  • a path whose existence can't be determined is an error, which the startup warning reports.

Tests

  • nickel_strings_stay_literal: five tricky strings make the round trip through nickel export unchanged, and three exact-output assertions pass.
  • load_if_exists_reports_a_symlink_loop_instead_of_defaulting (unix): a self-referential 0-AI-MANIFEST.deed is an error, not the defaults.

Checks run locally

  • cargo build: 0 warnings. The serde_json import in formatter.rs was unused after the rewrite and is gone.
  • cargo test: 818 passed, 0 failed.
  • cargo test --features http: 885 passed, 0 failed.
  • cargo clippy --locked --all-targets --features http,sarif,signing -- -D warnings: clean.
  • cargo fmt --check: exit 0.
  • git diff --summary: no mode changes.

Generated by Claude Code

…bsent manifest

Two findings from the CodeRabbit review of #302, both checked against
nickel 1.18.0 and Rust std before fixing.

- nickel_escape_string used JSON quoting. Nickel interpolates %{…}, so a
  report string such as the path /tmp/%{true} exported as /tmp/true. JSON's
  \b, \f and \u001f escapes are not Nickel escapes at all, so a control
  character made the file unparseable ("invalid escape sequence"). The
  escaper now writes \% for every %, \" \\ \n \r \t, and \u{XX} for other
  control characters. Test: a round trip through `nickel export` returns
  each tricky string unchanged.
- Manifest::default_path and load_if_exists used Path::exists(), which
  turns any metadata error (a self-referential symlink, a permission error)
  into false, so the CLI silently used the defaults. They now use
  try_exists(): only a definite absence gives the defaults, and an
  undeterminable path is an error that the startup warning reports. Test: a
  self-referential 0-AI-MANIFEST.deed is an error, not the defaults.

The unused serde_json import in formatter.rs goes with the old escaper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136P7ZoBy5xGnGDLk7wQ8jC
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8a8c205f-f6bf-40b6-be1e-7e421f370855
Commits

Reviewing files that changed from the base of the PR and between c5fc2c6 and 0a2303f.

Files selected for processing: 3

  • src/a2ml/mod.rs
  • src/report/formatter.rs
  • src/report/output.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 14, 2026 23:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T23:30:58.347522Z 0a2303f Draft marked ready
🔒 Security Review ✅ Completed 2026-11-14T23:32:14.820917Z 0a2303f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath merged commit f2c46ba into main Nov 14, 2026
73 checks passed
@hyperpolymath
hyperpolymath deleted the fix/nickel-escape-and-manifest-lookup branch November 14, 2026 23:36
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