Skip to content

Conversation

@cloutiertyler
Copy link
Contributor

@cloutiertyler cloutiertyler commented Nov 21, 2025

Description of Changes

Fixes #3729

I genuinely don't know what came over me.

API and ABI breaking changes

None

Expected complexity level and risk

1.5 very straightforward but not strictly trivial

Testing

Adds automated integration tests (written in Rust and run with cargo test, although note this comment from @matklad about integration tests for the future https://internals.rust-lang.org/t/running-test-crates-in-parallel/15639/2):

  • Can publish an updated module if no migration is required
  • Can publish an updated module if auto-migration is required (with the yes-break flag true/false)
  • Cannot publish if a manual migration is required
  • Can publish if a manual migration is required but the user specified --delete-data
  • Can publish if a manual migration is required by the user specified --delete-data=on-conflict
  • No data deletion occurs if no migration is required and --delete-data=on-conflict is specified

@cloutiertyler cloutiertyler changed the title tyler/fix-on-conflict Fixes issues with --delete-data=on-conflict Nov 21, 2025
bfops
bfops previously requested changes Nov 21, 2025
Copy link
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

From a black box perspective, I would like you to test the following cases, with each value of --delete-data:

  • no migration required
  • auto-migrateable (with the yes-break flag true/false)
  • manual migration required

Edit: I would like to consider making these into automated tests!

Given the original issue, please also spot-test spacetime dev.

@jdetter
Copy link
Collaborator

jdetter commented Nov 21, 2025

Shall we do a hotfix release with this?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issues with the --delete-data=on-conflict flag in the SpacetimeDB CLI's publish command. The main problem was that the data deletion prompt and logic were being executed at the wrong time in the publish flow, and the flag wasn't being properly respected when auto-migration was possible.

Key changes:

  • Fixed the logic for --delete-data=on-conflict to only delete data when a manual migration is required, not when auto-migration is available
  • Moved data deletion prompts and logic into the apply_pre_publish_if_needed function where migration decisions are made
  • Added support for --features flag to enable building Rust modules with different feature sets for testing
  • Added comprehensive integration tests to verify all migration scenarios

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/cli/src/subcommands/publish.rs Refactored data deletion logic to occur within migration decision flow, fixed handling of --delete-data=on-conflict
crates/cli/src/subcommands/build.rs Added --features flag support for Rust builds
crates/cli/src/tasks/rust.rs Updated build function to accept and pass features to cargo
crates/cli/src/tasks/mod.rs Added features parameter and validation for non-Rust modules
crates/cli/tests/publish.rs Added comprehensive integration tests for all publish/migration scenarios
crates/cli/tests/util.rs Added utility for spawning SpacetimeDB instances in tests
crates/cli/tests/server.rs Added basic server connectivity test
modules/module-test/src/lib.rs Added conditional compilation features for testing migrations
modules/module-test/Cargo.toml Added feature flags for migration testing
crates/testing/src/modules.rs Updated to pass new features parameter
crates/cli/src/subcommands/dev.rs Updated to use new build API with features parameter
crates/codegen/tests/snapshots/*.snap Updated snapshots to include generated code for new test table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bfops bfops added release-any To be landed in any release window bugfix Fixes something that was expected to work differently labels Nov 24, 2025
@jdetter jdetter added release-1.10.0 and removed release-any To be landed in any release window labels Nov 24, 2025
@bfops bfops changed the title Fixes issues with --delete-data=on-conflict Fixes issues with --delete-data=on-conflict Nov 25, 2025
bfops and others added 3 commits November 25, 2025 14:04
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
…ub.com:clockworklabs/SpacetimeDB into tyler/fix-on-conflict
@bfops bfops dismissed their stale review November 25, 2025 23:04

have reworked since this

Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

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

I haven't tested this but we at least test several different usages here. As Zeke pointed out, we need to add some more tests but we can do that later.

We also eventually want to change --features to just be a generic --build-args "..." where you can pass in arbitrary build options to build with (this would be useful for other langs as well). For now people can get around this by not using spacetime publish to build their wasm binary and instead build their wasm module manually and then use spacetime publish --bin-path ... .

I also made one small trivial change myself.


if clear_database != ClearMode::Always {
if clear_database == ClearMode::Always {
builder = confirm_and_clear(name_or_identity, force, builder)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

note that this now only happens in the case where we've passed a name_or_identity, but that's required if we pass --clear-database.

force: bool,
) -> Result<reqwest::RequestBuilder, anyhow::Error> {
// The caller enforces this
assert!(clear_database != ClearMode::Always);
Copy link
Collaborator

@bfops bfops Nov 26, 2025

Choose a reason for hiding this comment

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

note: we had worrying behavior where one of the teams smoketests would fail if we were calling this function/endpoint unconditionally

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created #3778 with the state of things that triggers that issue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that was expected to work differently release-1.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spacetime Dev fails on publish args mistake 1.9

5 participants