Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ test-ui: node_modules

.PHONY: sandbox-index
sandbox-index: compile
$(PREFIX)/bin/sourcemeta-one-index \
$(SANDBOX)/one-$(SANDBOX_CONFIGURATION).json \
$(OUTPUT)/sandbox --url $(SANDBOX_URL) --configuration
$(PREFIX)/bin/sourcemeta-one-index \
$(SANDBOX)/one-$(SANDBOX_CONFIGURATION).json \
$(OUTPUT)/sandbox --url $(SANDBOX_URL) --profile
Expand Down Expand Up @@ -142,6 +145,7 @@ docs: mkdocs.yml

.PHONY: public
public:
$(PREFIX)/bin/sourcemeta-one-index $(PUBLIC)/one.json $(OUTPUT)/public --configuration
$(PREFIX)/bin/sourcemeta-one-index $(PUBLIC)/one.json $(OUTPUT)/public --verbose
$(PREFIX)/bin/sourcemeta-one-server $(OUTPUT)/public 8000

Expand Down
8 changes: 5 additions & 3 deletions src/index/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ static auto index_main(const std::string_view &program,
const auto raw_configuration{sourcemeta::one::Configuration::read(
configuration_path, SOURCEMETA_ONE_COLLECTIONS)};

if (app.contains("verbose")) {
sourcemeta::core::prettify(raw_configuration, std::cerr);
std::cerr << "\n";
if (app.contains("configuration")) {
Copy link

Choose a reason for hiding this comment

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

--configuration returns before the --url override block later in index_main, so invocations like ... --url <...> --configuration will print the non-overridden URL (and other derived values) rather than the effective configuration; the Makefile now calls this combination in sandbox-index. Is that the intended behavior for the new option?

Severity: medium

Fix This in Augment

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

Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

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

P2: --configuration should be a read-only operation, but it still constructs Output before returning, which creates/scans the output directory. Consider moving the configuration-print/exit path before Output initialization so it doesn’t touch the filesystem when only dumping the configuration.

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

<comment>`--configuration` should be a read-only operation, but it still constructs `Output` before returning, which creates/scans the output directory. Consider moving the configuration-print/exit path before `Output` initialization so it doesn’t touch the filesystem when only dumping the configuration.</comment>

<file context>
@@ -102,9 +102,10 @@ static auto index_main(const std::string_view &program,
-  if (app.contains("verbose")) {
-    sourcemeta::core::prettify(raw_configuration, std::cerr);
-    std::cerr << "\n";
+  if (app.contains("configuration")) {
+    sourcemeta::core::prettify(raw_configuration, std::cout);
+    std::cout << "\n";
</file context>
Fix with Cubic

sourcemeta::core::prettify(raw_configuration, std::cout);
Copy link

Choose a reason for hiding this comment

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

In --configuration mode the JSON is written to stdout, but the program also prints the version banner to stdout at startup, so the overall stdout stream isn’t valid JSON (the new tests work around this via tail -n +2). If --configuration is meant for scripting/pipe use, this mixed output could be surprising.

Severity: low

Fix This in Augment

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

std::cout << "\n";
return EXIT_SUCCESS;
}

auto configuration{sourcemeta::one::Configuration::parse(raw_configuration)};
Expand Down Expand Up @@ -600,6 +601,7 @@ auto main(int argc, char *argv[]) noexcept -> int {
app.option("concurrency", {"c"});
app.flag("verbose", {"v"});
app.flag("profile", {"p"});
app.flag("configuration", {"g"});
app.parse(argc, argv);
const std::string_view program{argv[0]};

Expand Down
3 changes: 3 additions & 0 deletions test/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ if(ONE_INDEX)
sourcemeta_one_test_cli(common index rebuild-to-empty)
sourcemeta_one_test_cli(common index verbose-long)
sourcemeta_one_test_cli(common index verbose-short)
sourcemeta_one_test_cli(common index configuration-long)
sourcemeta_one_test_cli(common index configuration-short)
sourcemeta_one_test_cli(common index no-base-uri)

if(ONE_ENTERPRISE)
sourcemeta_one_test_cli(enterprise index no-options)
sourcemeta_one_test_cli(enterprise index no-output)
sourcemeta_one_test_cli(enterprise index sourcemeta-std)
else()
sourcemeta_one_test_cli(community index no-options)
sourcemeta_one_test_cli(community index no-output)
Expand Down
55 changes: 55 additions & 0 deletions test/cli/index/common/configuration-long.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << EOF > "$TMP/one.json"
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "./schemas"
}
}
}
}
}
EOF

mkdir "$TMP/schemas"

cat << 'EOF' > "$TMP/schemas/foo.json"
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/foo"
}
EOF

"$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt"
cat << EOF > "$TMP/expected.txt"
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "$(realpath "$TMP")/schemas"
}
}
}
},
"html": {
"name": "Sourcemeta",
"description": "The next-generation JSON Schema platform"
}
}
EOF
diff "$TMP/output.txt" "$TMP/expected.txt"
55 changes: 55 additions & 0 deletions test/cli/index/common/configuration-short.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << EOF > "$TMP/one.json"
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "./schemas"
}
}
}
}
}
EOF

mkdir "$TMP/schemas"

cat << 'EOF' > "$TMP/schemas/foo.json"
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/foo"
}
EOF

"$1" "$TMP/one.json" "$TMP/output" -g | tail -n +2 > "$TMP/output.txt"
cat << EOF > "$TMP/expected.txt"
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "$(realpath "$TMP")/schemas"
}
}
}
},
"html": {
"name": "Sourcemeta",
"description": "The next-generation JSON Schema platform"
}
}
EOF
diff "$TMP/output.txt" "$TMP/expected.txt"
17 changes: 0 additions & 17 deletions test/cli/index/common/verbose-long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ remove_threads_information "$TMP/output.txt"
cat << EOF > "$TMP/expected.txt"
Writing output to: $(realpath "$TMP")/output
Using configuration: $(realpath "$TMP")/one.json
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "$(realpath "$TMP")/schemas"
}
}
}
},
"html": {
"name": "Sourcemeta",
"description": "The next-generation JSON Schema platform"
}
}
Detecting: $(realpath "$TMP")/schemas/foo.json (#1)
https://example.com/foo => https://sourcemeta.com/example/schemas/foo
(100%) Ingesting: https://sourcemeta.com/example/schemas/foo
Expand Down
17 changes: 0 additions & 17 deletions test/cli/index/common/verbose-short.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ remove_threads_information "$TMP/output.txt"
cat << EOF > "$TMP/expected.txt"
Writing output to: $(realpath "$TMP")/output
Using configuration: $(realpath "$TMP")/one.json
{
"url": "https://sourcemeta.com/",
"contents": {
"example": {
"contents": {
"schemas": {
"baseUri": "https://example.com/",
"path": "$(realpath "$TMP")/schemas"
}
}
}
},
"html": {
"name": "Sourcemeta",
"description": "The next-generation JSON Schema platform"
}
}
Detecting: $(realpath "$TMP")/schemas/foo.json (#1)
https://example.com/foo => https://sourcemeta.com/example/schemas/foo
(100%) Ingesting: https://sourcemeta.com/example/schemas/foo
Expand Down
2 changes: 1 addition & 1 deletion test/cli/index/community/sourcemeta-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cat << EOF > "$TMP/one.json"
}
EOF

"$1" "$TMP/one.json" "$TMP/output" 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
"$1" "$TMP/one.json" "$TMP/output" --configuration 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
test "$CODE" = "1" || exit 1

cat << EOF > "$TMP/expected.txt"
Expand Down
54 changes: 54 additions & 0 deletions test/cli/index/enterprise/sourcemeta-std.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << EOF > "$TMP/one.json"
{
"url": "https://example.com/",
"extends": [ "@sourcemeta/std/v0" ]
}
EOF

"$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt"
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

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

P2: The pipeline only checks tail's exit status, so a failure in the index command can be masked. Run the command separately (or capture its output) so errexit stops the test on failure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/cli/index/enterprise/sourcemeta-std.sh, line 17:

<comment>The pipeline only checks `tail`'s exit status, so a failure in the index command can be masked. Run the command separately (or capture its output) so `errexit` stops the test on failure.</comment>

<file context>
@@ -0,0 +1,54 @@
+}
+EOF
+
+"$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt"
+
+cat << EOF > "$TMP/expected.txt"
</file context>
Fix with Cubic


cat << EOF > "$TMP/expected.txt"
{
"contents": {
"sourcemeta": {
"title": "Sourcemeta",
"description": "A provider of premium tooling and services to support JSON Schema use in production",
"email": "hello@sourcemeta.com",
"github": "sourcemeta",
"website": "https://www.sourcemeta.com",
"contents": {
"std": {
"title": "The JSON Schema Standard Library",
"description": "A growing collection of hand-crafted high-quality schemas by Sourcemeta",
"email": "hello@sourcemeta.com",
"github": "sourcemeta/std",
"website": "https://www.sourcemeta/products/std",
"contents": {
"v0": {
"x-sourcemeta-one:provenance": "@sourcemeta/std/v0",
"path": "$ONE_PREFIX/share/sourcemeta/one/collections/sourcemeta/std/v0/schemas/2020-12",
"baseUri": "https://example.com/"
}
}
}
}
}
},
"url": "https://example.com/",
"html": {
"name": "Sourcemeta",
"description": "The next-generation JSON Schema platform"
}
}
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"