Skip to content

Match configuration resolve keys by canonical URI - #819

Open
jviotti wants to merge 1 commit into
mainfrom
misc-test
Open

Match configuration resolve keys by canonical URI#819
jviotti wants to merge 1 commit into
mainfrom
misc-test

Conversation

@jviotti

@jviotti jviotti commented Aug 12, 2026

Copy link
Copy Markdown
Member

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

Review in cubic

@augmentcode

augmentcode Bot commented Aug 12, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR tightens and consolidates CLI test coverage while fixing two behaviors.

Changes:

  • Removes duplicate schema-validation errors emitted during benchmark failures.
  • Allows configuration resolve keys written with an empty URI fragment to match fragment-stripped identifiers.
  • Adds an install test covering an empty-fragment resolve mapping and lockfile output.
  • Strengthens bundle, compile, lint, and codegen tests so their fixtures exercise the intended behavior.
  • Verifies failed lint fixes leave individual schemas and recursive directory inputs unchanged.
  • Makes help-output assertions version-independent via the $VERSION placeholder.
  • Renames CI HTTP tests to describe non-JSON responses more accurately.
  • Removes redundant or non-observable tests and updates CMake registrations accordingly.

Technical Notes: The resolver retains its existing exact and .json fallback behavior, with added empty-fragment lookup handling.

🤖 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. 1 suggestion posted.

Fix All in Augment

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

Comment thread src/resolver.h Outdated
// The identifier reaches us with an empty fragment already dropped, while the
// configuration keeps whatever the user typed. Without this, a key written as
// `https://example.com#` would silently never match anything
if (match == resolve_map.cend() && !identifier.ends_with("#")) {

@augmentcode augmentcode Bot Aug 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

find_resolve_match applies the .json aliases before normalizing an empty fragment. Consequently, a mapping such as https://example.com/types/name.json# will not resolve a reference to https://example.com/types/name, although the equivalent key without # does; this means an empty-fragment mapping does not fully behave like the same mapping without the fragment.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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

All reported issues were addressed across 22 files

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

Re-trigger cubic

Comment thread test/compile/pass_patternproperties.clitest
Comment thread src/resolver.h Outdated
Comment thread src/command_validate.cc Outdated

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

All reported issues were addressed across 3 files (changes from recent commits).

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

Re-trigger cubic

Comment thread src/resolver.h Outdated
Comment thread src/resolver.h Outdated

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

2 issues found across 1 file (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/resolver.h">

<violation number="1" location="src/resolver.h:45">
P1: When a configuration contains canonical-equivalent `resolve` keys, `canonical_resolve_map` silently keeps one mapping, so the other spelling can resolve to the wrong schema. Preserve exact-key precedence or retain all entries that share a canonical key.</violation>

<violation number="2" location="src/resolver.h:87">
P2: Every `resolve_map_uri(configuration, ...)` call rebuilds and canonicalizes the full map. `command_install.cc:57` uses this overload for each dependency resolution, so large installs pay repeated allocations; reuse a cached canonical map.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/resolver.h
std::unordered_map<std::string, std::string> result;
result.reserve(resolve_map.size());
for (const auto &entry : resolve_map) {
result.emplace(sourcemeta::core::URI::canonicalize(entry.first),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: When a configuration contains canonical-equivalent resolve keys, canonical_resolve_map silently keeps one mapping, so the other spelling can resolve to the wrong schema. Preserve exact-key precedence or retain all entries that share a canonical key.

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

<comment>When a configuration contains canonical-equivalent `resolve` keys, `canonical_resolve_map` silently keeps one mapping, so the other spelling can resolve to the wrong schema. Preserve exact-key precedence or retain all entries that share a canonical key.</comment>

<file context>
@@ -34,44 +34,58 @@ namespace sourcemeta::jsonschema {
+  std::unordered_map<std::string, std::string> result;
+  result.reserve(resolve_map.size());
+  for (const auto &entry : resolve_map) {
+    result.emplace(sourcemeta::core::URI::canonicalize(entry.first),
+                   entry.second);
+  }
</file context>

Comment thread src/resolver.h
static inline auto
resolve_map_uri(const sourcemeta::blaze::Configuration &configuration,
const std::string &identifier) -> std::optional<std::string> {
return resolve_map_uri(canonical_resolve_map(configuration.resolve),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Every resolve_map_uri(configuration, ...) call rebuilds and canonicalizes the full map. command_install.cc:57 uses this overload for each dependency resolution, so large installs pay repeated allocations; reuse a cached canonical map.

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

<comment>Every `resolve_map_uri(configuration, ...)` call rebuilds and canonicalizes the full map. `command_install.cc:57` uses this overload for each dependency resolution, so large installs pay repeated allocations; reuse a cached canonical map.</comment>

<file context>
@@ -34,44 +34,58 @@ namespace sourcemeta::jsonschema {
+static inline auto
+resolve_map_uri(const sourcemeta::blaze::Configuration &configuration,
+                const std::string &identifier) -> std::optional<std::string> {
+  return resolve_map_uri(canonical_resolve_map(configuration.resolve),
+                         configuration.base_path, identifier);
 }
</file context>

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti jviotti changed the title Misc test cleanups Match configuration resolve keys by canonical URI Aug 12, 2026
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