Repository navigation
Resolve schema collection references by file, as the JSON Schema CLI does - #1294
Conversation
…does Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
There was a problem hiding this comment.
Benchmark (community)
Details
| Benchmark suite | Current: 8dc48ab | Previous: e85241d | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
237 ms |
189 ms |
1.25 |
Add one schema (100 existing) |
45 ms |
33 ms |
1.36 |
Add one schema (1000 existing) |
98 ms |
155 ms |
0.63 |
Add one schema (10000 existing) |
788 ms |
860 ms |
0.92 |
Update one schema (1 existing) |
31 ms |
29 ms |
1.07 |
Update one schema (101 existing) |
41 ms |
35 ms |
1.17 |
Update one schema (1001 existing) |
103 ms |
101 ms |
1.02 |
Update one schema (10001 existing) |
1080 ms |
793 ms |
1.36 |
Cached rebuild (1 existing) |
12 ms |
8 ms |
1.50 |
Cached rebuild (101 existing) |
16 ms |
11 ms |
1.45 |
Cached rebuild (1001 existing) |
43 ms |
37 ms |
1.16 |
Cached rebuild (10001 existing) |
343 ms |
282 ms |
1.22 |
Index 100 schemas |
445 ms |
524 ms |
0.85 |
Index 1000 schemas |
1413 ms |
1586 ms |
0.89 |
Index 10000 schemas |
12783 ms |
16630 ms |
0.77 |
Index 10000 schemas (custom meta-schema) |
14896 ms |
16491 ms |
0.90 |
Index 10000 schemas ($ref fan-out) |
15285 ms |
16950 ms |
0.90 |
test/e2e/html: Schema Fetch (p50) |
395 us |
301 us |
1.31 |
test/e2e/html: Schema Fetch (p99) |
477 us |
351 us |
1.36 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Benchmark (enterprise)
Details
| Benchmark suite | Current: 8dc48ab | Previous: e85241d | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
289 ms |
341 ms |
0.85 |
Add one schema (100 existing) |
104 ms |
115 ms |
0.90 |
Add one schema (1000 existing) |
168 ms |
186 ms |
0.90 |
Add one schema (10000 existing) |
925 ms |
802 ms |
1.15 |
Update one schema (1 existing) |
100 ms |
108 ms |
0.93 |
Update one schema (101 existing) |
109 ms |
118 ms |
0.92 |
Update one schema (1001 existing) |
165 ms |
179 ms |
0.92 |
Update one schema (10001 existing) |
879 ms |
825 ms |
1.07 |
Cached rebuild (1 existing) |
11 ms |
12 ms |
0.92 |
Cached rebuild (101 existing) |
14 ms |
15 ms |
0.93 |
Cached rebuild (1001 existing) |
38 ms |
51 ms |
0.75 |
Cached rebuild (10001 existing) |
295 ms |
305 ms |
0.97 |
Index 100 schemas |
412 ms |
636 ms |
0.65 |
Index 1000 schemas |
1476 ms |
1504 ms |
0.98 |
Index 10000 schemas |
12964 ms |
14122 ms |
0.92 |
Index 10000 schemas (custom meta-schema) |
15864 ms |
15801 ms |
1.00 |
Index 10000 schemas ($ref fan-out) |
15733 ms |
17213 ms |
0.91 |
enterprise/e2e/auth: Schema Anonymous (p50) |
291 us |
400 us |
0.73 |
enterprise/e2e/auth: Schema Anonymous (p99) |
395 us |
518 us |
0.76 |
enterprise/e2e/auth: Schema API Key Identity (p50) |
294 us |
405 us |
0.73 |
enterprise/e2e/auth: Schema API Key Identity (p99) |
372 us |
513 us |
0.73 |
enterprise/e2e/auth: Schema API Key SHA256 (p50) |
300 us |
412 us |
0.73 |
enterprise/e2e/auth: Schema API Key SHA256 (p99) |
366 us |
526 us |
0.70 |
enterprise/e2e/auth: Schema JWT (p50) |
410 us |
537 us |
0.76 |
enterprise/e2e/auth: Schema JWT (p99) |
517 us |
685 us |
0.75 |
test/e2e/html: Schema Fetch (p50) |
297 us |
408 us |
0.73 |
test/e2e/html: Schema Fetch (p99) |
355 us |
499 us |
0.71 |
This comment was automatically generated by workflow using github-action-benchmark.
🤖 Augment PR SummarySummary: This PR changes collection Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
| continue; | ||
| } | ||
|
|
||
| if (owner != nullptr) { |
There was a problem hiding this comment.
This treats a target as ambiguous before considering whether a candidate collection ignores it. A file under overlapping collections that is ignored by all but one is indexed only once and has a single served URI, but this now rejects that valid target instead of routing it to the collection that actually serves it.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| // A target the collection ignores is never indexed, so there is no URI | ||
| // to route the reference to | ||
| if (owner == nullptr || |
There was a problem hiding this comment.
Ownership validation checks ignore but not the collection's extension filter. A target can therefore be rebased to a URI even though discovery skips that file (for example, a .json target in a collection configured for .schema.json), leaving every reference through this mapping unresolved during indexing.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
1 issue found across 23 files
You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="test/cli/index/community/snapshot-no-self-collection-resolve-file-target.clitest">
<violation number="1" location="test/cli/index/community/snapshot-no-self-collection-resolve-file-target.clitest:116">
P2: This snapshot checks only that both schemas' artifact paths exist, so it passes even if `urn:example:shared` never resolves. Assert that `uses`' dependency output contains the edge to `shared`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ./version.json | ||
| EOF | ||
|
|
||
| COMPARE manifest.txt AGAINST expected.txt |
There was a problem hiding this comment.
P2: This snapshot checks only that both schemas' artifact paths exist, so it passes even if urn:example:shared never resolves. Assert that uses' dependency output contains the edge to shared.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At test/cli/index/community/snapshot-no-self-collection-resolve-file-target.clitest, line 116:
<comment>This snapshot checks only that both schemas' artifact paths exist, so it passes even if `urn:example:shared` never resolves. Assert that `uses`' dependency output contains the edge to `shared`.</comment>
<file context>
@@ -0,0 +1,116 @@
+./version.json
+EOF
+
+COMPARE manifest.txt AGAINST expected.txt
</file context>
There was a problem hiding this comment.
2 issues found across 11 files (changes from recent commits).
You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="test/cli/index/common/fail-resolve-target-not-a-schema.clitest">
<violation number="1" location="test/cli/index/common/fail-resolve-target-not-a-schema.clitest:7">
P2: This fixture can fail during ordinary collection ingestion, independently of the `resolve` entry, so it does not verify that resolving this target rejects a non-schema. Isolate the target from automatic collection ingestion so the test catches regressions in resolve-target validation.</violation>
</file>
<file name="test/unit/resolver/resolver_test.cc">
<violation number="1" location="test/unit/resolver/resolver_test.cc:704">
P2: This expectation blesses a broken reference: `/example/...` resolves outside the resolver's `/v1/catalog` prefix. Keep the target under that prefix, or make rebasing use the resolver's server URL.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| { "$schema": "https://json-schema.org/draft/2020-12/schema" } | ||
| EOF | ||
|
|
||
| WRITE schemas/notes.json UNTIL EOF |
There was a problem hiding this comment.
P2: This fixture can fail during ordinary collection ingestion, independently of the resolve entry, so it does not verify that resolving this target rejects a non-schema. Isolate the target from automatic collection ingestion so the test catches regressions in resolve-target validation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At test/cli/index/common/fail-resolve-target-not-a-schema.clitest, line 7:
<comment>This fixture can fail during ordinary collection ingestion, independently of the `resolve` entry, so it does not verify that resolving this target rejects a non-schema. Isolate the target from automatic collection ingestion so the test catches regressions in resolve-target validation.</comment>
<file context>
@@ -4,8 +4,8 @@ WRITE schemas/sample.json UNTIL EOF
-WRITE schemas/notes.txt UNTIL EOF
-This file is not a schema
+WRITE schemas/notes.json UNTIL EOF
+[ "not a schema" ]
EOF
</file context>
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "http://localhost:8000/v1/catalog/example/2020-12-ref-needs-rebase", | ||
| "$ref": "/v1/catalog/example/2020-12-with-id" | ||
| "$ref": "/example/2020-12-with-id" |
There was a problem hiding this comment.
P2: This expectation blesses a broken reference: /example/... resolves outside the resolver's /v1/catalog prefix. Keep the target under that prefix, or make rebasing use the resolver's server URL.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At test/unit/resolver/resolver_test.cc, line 704:
<comment>This expectation blesses a broken reference: `/example/...` resolves outside the resolver's `/v1/catalog` prefix. Keep the target under that prefix, or make rebasing use the resolver's server URL.</comment>
<file context>
@@ -698,7 +701,7 @@ TEST(path_url_ref_needs_rebase) {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:8000/v1/catalog/example/2020-12-ref-needs-rebase",
- "$ref": "/v1/catalog/example/2020-12-with-id"
+ "$ref": "/example/2020-12-with-id"
})JSON");
}
</file context>
Signed-off-by: Juan Cruz Viotti jv@jviotti.com