Skip to content

Reject non-Spin runtime config for config commands - #498

Open
prk-Jr wants to merge 2 commits into
mainfrom
fix/458-spin-runtime-config
Open

prk-Jr wants to merge 2 commits into
mainfrom
fix/458-spin-runtime-config

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Reject explicit --runtime-config for non-Spin config push and config diff before configuration-file access or provider activity, so unsupported options cannot silently succeed.
  • Enforce the rule once in shared typed entrypoints, covering direct library callers, generated application CLIs, and the demo. Preserve case-insensitive adapter matching, Spin backend/path behavior, and portable --app-config.
  • Explain “Spin only” in both commands' help and distinguish host runtime settings from the app-config payload in documentation.

Changes

Crate / File Change
edgezero-cli/src/config.rs Shared early validation; adapter/option matrix, provider-ordering tests, and Spin path round-trips.
edgezero-cli/src/args.rs Spin-only runtime-config help and help regression coverage.
edgezero-cli/tests/generated_project_builds.rs Exercise both generated commands across non-Spin adapters without risking live provider calls.
examples/app-demo/crates/app-demo-cli/tests/config_flow.rs Check rejection through the demo binary.
docs/guide/cli-reference.md Document rejection and distinguish host runtime settings from portable application configuration.

Closes

Closes #458

Test plan

Historical author-reported local verification below (original head unrecorded unless an explicit SHA is given). These results, counts, timings and negative controls were not rerun in this audit, and their underlying local logs were unavailable; checked boxes retain the original report. At the current head 1095f9d6, all 28 reported hosted checks are passing.

Local verification completed before publication using Rust 1.98.1 and Node 24.20.0. The PR is now non-draft; current reported hosted checks are passing.

  • cargo test --workspace --all-targets
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • WASM builds: wasm32-wasip1 (Fastly) / wasm32-wasip2 (Spin) / wasm32-unknown-unknown (Cloudflare)
  • examples/app-demo full workspace tests
  • Docs build
  • Manual testing via edgezero serve --adapter axum
  • Other: 227 CLI library tests; 5 demo config_flow tests; explicit generated-project host and all three WASM compilation checks; Spin wasm32-wasip2 check; demo formatting; docs ESLint and Prettier.

The initial sandbox socket/DNS restrictions and disk-space failures were resolved before successful reruns. Workspace socket tests ran outside the sandbox; generated-project verification ran offline with cached dependencies. No live provider operation was performed.

Checklist

  • Changes follow CLAUDE.md conventions
  • No Tokio deps added to core or adapter crates
  • Route params use {id} syntax (not :id)
  • Types imported from edgezero_core (not http crate)
  • Store wiring goes through KvRegistry / ConfigRegistry / SecretRegistry (not the legacy single-handle setters)
  • New code has tests
  • No secrets or credentials committed

@prk-Jr prk-Jr self-assigned this Nov 13, 2026
@prk-Jr
prk-Jr marked this pull request as ready for review November 13, 2026 12:57

@dhruv8sh dhruv8sh left a comment

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.

PR Review

Summary

config push and config diff now reject --runtime-config for every adapter except Spin. The check runs at the start of both typed library entrypoints, before any manifest access, I/O, or provider command. Help text and docs now separate Spin's host runtime settings from the app-config payload. The change is small, well tested, and covers the whole #458 checklist. Approving; the items below are non-blocking.

😃 Praise

  • 😃 The check is placed where it can't be bypassed (crates/edgezero-cli/src/config.rs:456, :615). It's the first statement of both run_config_push_typed and run_config_diff_typed, so library callers, generated CLIs, and the demo all get it without duplicating it.
  • 😃 Tests prove nothing reaches a provider (crates/edgezero-cli/src/config.rs:2775, :2818). Failing, op-logging fake fastly/wrangler/spin binaries on PATH show no calls, no .edgezero state, and no runtime-file changes. Spin's explicit and default paths are covered with and without --local, including a mixed-case adapter name.
  • 😃 Docs clearly separate host runtime settings from the app-config payload (docs/guide/cli-reference.md:396, :469).

Findings

Non-blocking

  • 🤔 Hardcoded adapter name in the shared CLI (crates/edgezero-cli/src/config.rs:1358).
    • validate_runtime_config_adapter branches on adapter.eq_ignore_ascii_case("spin"). The same file says at line 1612: No `if adapter == "spin"` branches here.
    • It also means an out-of-tree adapter can never receive AdapterPushContext::runtime_config_path, which the public registry documents as a generic hook (crates/edgezero-adapter/src/registry.rs:193-199).
    • Fix: add a capability method so the rule lives in one place and the early ordering is kept (get_adapter doesn't need the manifest):
      // trait Adapter
      fn accepts_runtime_config(&self) -> bool { false }
      // edgezero-adapter-spin: override to return true
      // config.rs
      if runtime_config.is_some()
          && !adapter_registry::get_adapter(adapter).is_some_and(|a| a.accepts_runtime_config())
      { /* error */ }
      If you'd rather keep this PR minimal, a comment at line 1358 explaining the exception is enough.
  • ⛏ Misleading error for an unknown or typo'd adapter (crates/edgezero-cli/src/config.rs:1359). --adapter spn --runtime-config x reports "only supported with --adapter spin" instead of "not configured". Consider naming the adapter: format!("--runtime-config is only supported with --adapter spin (got `--adapter {adapter}`)"). If so, update the assertions at config.rs:2762, generated_project_builds.rs:78, and config_flow.rs:370.
  • 📝 The help test only checks long help (crates/edgezero-cli/src/args.rs:560-566). The short -h currently shows the same "Spin only" text, so nothing is wrong today. This only matters if a paragraph break is added later.

CI Status

Run locally on the pinned Rust 1.98.1:

  • fmt: PASS
  • clippy: PASS
  • tests: PASS
  • check --features "fastly cloudflare spin": PASS
  • spin wasm32-wasip2 check: PASS

@ChristianPavilonis ChristianPavilonis left a comment

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.

😃 The shared validation at crates/edgezero-cli/src/config.rs:456 and :615 rejects unsupported options before file/provider access. Regression coverage exercises mixed-case adapters, local/dry-run combinations, and explicit/default Spin paths. No new actionable findings; all required local checks and supplementary verification passed.

This branch has not been deployed

No deployments
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.

Reject --runtime-config for non-Spin adapters

3 participants