Skip to content

Fix generate config target fallback#5432

Open
clockwork-labs-bot wants to merge 2 commits into
masterfrom
bot/generate-config-target-fallback
Open

Fix generate config target fallback#5432
clockwork-labs-bot wants to merge 2 commits into
masterfrom
bot/generate-config-target-fallback

Conversation

@clockwork-labs-bot

@clockwork-labs-bot clockwork-labs-bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Fixes #4475.

When spacetime generate loads spacetime.json but the selected config target has no generate entries, preserve the selected target's entity fields instead of falling back to an empty config.

This keeps root-level and child-level fields such as module-path available to generate even when the user is driving language/output settings from CLI flags. Unsupported entity fields such as database and server are filtered through the command schema before building the fallback CommandConfig.

This also moves that filtering into CommandSchema so command fallbacks do not need to hand-roll schema-key filtering.

API and ABI breaking changes

None.

Expected complexity level and risk

The change is mostly local to CLI config resolution for spacetime generate, but it touches the shared config schema helper so the fallback path can filter entity fields consistently.

Testing

  • Focused generate unit tests:
LC_ALL=C LANG=C PATH=/Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin:$PATH \
  /Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin/cargo test \
  -p spacetimedb-cli subcommands::generate::tests:: -- --nocapture
  • Focused CLI generate smoketests, including root fallback, selected child target fallback, and inherited grandchild target fallback:
LC_ALL=C LANG=C PATH=/Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin:$PATH \
  /Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin/cargo build \
  -p spacetimedb-cli -p spacetimedb-standalone --release \
  --features spacetimedb-standalone/allow_loopback_http_for_tests

LC_ALL=C LANG=C PATH=/Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin:$PATH \
  /Users/clockworklabs/.rustup/toolchains/1.93.0-aarch64-apple-darwin/bin/cargo test \
  -p spacetimedb-smoketests --test integration cli::generate:: -- --nocapture
  • Manual verification recipe:
tmpdir="$(mktemp -d)"
spacetime init --non-interactive --lang rust --project-path "$tmpdir" test-project
mv "$tmpdir/spacetimedb" "$tmpdir/server-rust"
cat > "$tmpdir/spacetime.json" <<'JSON'
{
  "module-path": "server-rust"
}
JSON
spacetime build --module-path "$tmpdir/server-rust"
(
  cd "$tmpdir"
  spacetime generate --lang rust --out-dir bindings
)
test -f "$tmpdir/bindings/lib.rs" -o -f "$tmpdir/bindings/mod.rs"

}
}

fn fallback_generate_configs_from_targets<'a>(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

document what this function's for

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.

spacetime generate: "module-path" was not read correctly from the configuration file

2 participants