Skip to content

Print validate and metaschema paths relative to the working directory - #853

Merged
jviotti merged 3 commits into
mainfrom
relative-paths
Sep 7, 2026
Merged

jviotti merged 3 commits into
mainfrom
relative-paths

Conversation

@jviotti

@jviotti jviotti commented Sep 7, 2026

Copy link
Copy Markdown
Member

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Review in cubic

…tory

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 125 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/validate/fail_yaml_multi_one_verbose.clitest">

<violation number="1" location="test/validate/fail_yaml_multi_one_verbose.clitest:26">
P3: The verbose `validate` output is now inconsistent: the ok/matches/fail lines print instance and schema paths relative to the working directory, but the adjacent "Interpreting input as YAML multi-document" line (src/input.h:403) still prints the absolute path via canonical.generic_string(). Since the PR's stated goal is to print paths relative to the working directory, confirm whether this message should also be made relative for consistent output in a single run.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread test/metaschema/fail_json.clitest
Comment thread test/validate/pass_entrypoint_pointer_fragment.clitest
Comment thread test/validate/fail_jsonl_continue.clitest
Comment thread test/validate/pass_stdin_instance_verbose.clitest
Comment thread test/validate/fail_jsonl_gz_continue.clitest
Comment thread test/validate/fail_many_continue_verbose.clitest
2> ok: [CWD]/instance.yaml (entry #1)
2> matches [CWD]/schema.json
2> fail: [CWD]/instance.yaml (entry #2)
2> ok: instance.yaml (entry #1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The verbose validate output is now inconsistent: the ok/matches/fail lines print instance and schema paths relative to the working directory, but the adjacent "Interpreting input as YAML multi-document" line (src/input.h:403) still prints the absolute path via canonical.generic_string(). Since the PR's stated goal is to print paths relative to the working directory, confirm whether this message should also be made relative for consistent output in a single run.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/validate/fail_yaml_multi_one_verbose.clitest, line 26:

<comment>The verbose `validate` output is now inconsistent: the ok/matches/fail lines print instance and schema paths relative to the working directory, but the adjacent "Interpreting input as YAML multi-document" line (src/input.h:403) still prints the absolute path via canonical.generic_string(). Since the PR's stated goal is to print paths relative to the working directory, confirm whether this message should also be made relative for consistent output in a single run.</comment>

<file context>
@@ -23,9 +23,9 @@ REPLACE $CWD WITH '[CWD]' IN result_0.txt
-2> ok: [CWD]/instance.yaml (entry #1)
-2>   matches [CWD]/schema.json
-2> fail: [CWD]/instance.yaml (entry #2)
+2> ok: instance.yaml (entry #1)
+2>   matches schema.json
+2> fail: instance.yaml (entry #2)
</file context>

Comment thread test/metaschema/fail_directory.clitest
Comment thread test/validate/fail_stdin_schema_validation.clitest
Comment thread src/error.h
@augmentcode

augmentcode Bot commented Sep 7, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR makes user-facing paths from validate and metaschema relative to the current working directory.

Changes:

  • Adds relative_path_string alongside the existing stdin-aware path formatter.
  • Canonicalizes paths safely, then computes a lexical path relative to the canonical working directory.
  • Preserves the stable synthetic identifier used for standard-input documents.
  • Updates validate benchmark, verbose success, failure, and JSON correlation output.
  • Updates metaschema verbose, failure, and JSON correlation output.
  • Formats the schema path in validate verbose output using the same helper.

Technical Notes:

  • Paths outside the working directory are rendered with .. segments; unrelatable paths retain their canonical form.
  • Regression expectations are updated across validation and metaschema command tests, including FUSE coverage.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 206 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/command_validate.cc">

<violation number="1" location="src/command_validate.cc:273">
P3: `weakly_canonical` resolves symlinks, so the path printed in the `ok:`/`fail:`/`matches` (verbose) and benchmark output is the resolved target, not the path the user typed. For a schema or instance reached through a symlink (e.g. `../schema.json` -> a file outside the working tree, or a path whose ancestor is a symlink), the display path becomes an absolute or `..`-heavy resolved location instead of the argument the user supplied, which is what `relative_path_string`'s comment (`// Per instance output names paths the way the user did`) promises. Confirm this is intended, or derive the display path lexically (`std::filesystem::absolute` + `lexically_normal`) instead of resolving symlinks when you only need a working-directory-relative display name.</violation>
</file>

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

Re-trigger cubic

Comment thread src/command_validate.cc
: std::filesystem::path(schema_path)};
const auto schema_resolution_base{
schema_from_stdin ? stdin_path() : std::filesystem::path(schema_path)};
const auto schema_display_path{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: weakly_canonical resolves symlinks, so the path printed in the ok:/fail:/matches (verbose) and benchmark output is the resolved target, not the path the user typed. For a schema or instance reached through a symlink (e.g. ../schema.json -> a file outside the working tree, or a path whose ancestor is a symlink), the display path becomes an absolute or ..-heavy resolved location instead of the argument the user supplied, which is what relative_path_string's comment (// Per instance output names paths the way the user did) promises. Confirm this is intended, or derive the display path lexically (std::filesystem::absolute + lexically_normal) instead of resolving symlinks when you only need a working-directory-relative display name.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/command_validate.cc, line 273:

<comment>`weakly_canonical` resolves symlinks, so the path printed in the `ok:`/`fail:`/`matches` (verbose) and benchmark output is the resolved target, not the path the user typed. For a schema or instance reached through a symlink (e.g. `../schema.json` -> a file outside the working tree, or a path whose ancestor is a symlink), the display path becomes an absolute or `..`-heavy resolved location instead of the argument the user supplied, which is what `relative_path_string`'s comment (`// Per instance output names paths the way the user did`) promises. Confirm this is intended, or derive the display path lexically (`std::filesystem::absolute` + `lexically_normal`) instead of resolving symlinks when you only need a working-directory-relative display name.</comment>

<file context>
@@ -270,6 +270,10 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options)
                                     : std::filesystem::path(schema_path)};
   const auto schema_resolution_base{
       schema_from_stdin ? stdin_path() : std::filesystem::path(schema_path)};
+  const auto schema_display_path{
+      schema_from_stdin
+          ? stdin_path()
</file context>

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
jviotti merged commit 8053cb6 into main Sep 7, 2026
16 checks passed
@jviotti
jviotti deleted the relative-paths branch September 7, 2026 17:43
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.

1 participant