dbt-labs/dbt-core · error
clap requires --environment unless --sdist-out
Error message
clap requires --environment unless --sdist-out
What it means
Invariant expect in the publish CLI's execute: clap's `requires` rule guarantees that when no --sdist-out is given, --environment was provided, so unwrapping args.environment must succeed. Fires only if the clap argument definition and this code drift apart — an internal bug, not a user input error.
Solutions
- Keep the clap `requires` attributes in sync with the expects in execute
- Add a CLI parsing test covering the --environment/--sdist-out matrix
- Report as an internal bug in dbt-ci publish
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/dbt-ci/src/publish.rs:166 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/b856114aa5a0aea6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-ci/src/publish.rs:166
return ExitCode::from(2);
}
};
// Build-only mode: assemble the sdist into `--sdist-out` and stop. The
// release pipeline stages it to S3/CDN itself, so no upload target is needed.
if let Some(out_dir) = &args.sdist_out {
return match rt.block_on(build_only_sdist(&args, &spec, out_dir)) {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e:#}");
ExitCode::from(2)
}
};
}
let target = match PublishTarget::from_env(
args.environment
.expect("clap requires --environment unless --sdist-out"),
) {
Ok(t) => t,
Err(e) => {
eprintln!("error: {e:#}");
return ExitCode::from(64);
}
};
match rt.block_on(run_publish(&args, &spec, target)) {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e:#}");
ExitCode::from(2)
}
}
}
/// Builds the download-at-install sdist into `out_dir` without uploading it.
async fn build_only_sdist(View on GitHub (pinned to 0267ce9170)