Skip to content

feat(deploy): per-board deploy method validation + fail-fast (#692) - #708

Merged
zackees merged 1 commit into
mainfrom
feat/692-deploy-method-validation
Jun 20, 2026
Merged

feat(deploy): per-board deploy method validation + fail-fast (#692)#708
zackees merged 1 commit into
mainfrom
feat/692-deploy-method-validation

Conversation

@zackees

@zackeeszackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

#692. Pre-deploy guard against picking an unsupported upload_protocol — today's failure mode is a 30-180 s backend timeout that doesn't say 'this board doesn't do OTA'. Now it fails fast with a structured error naming the supported alternatives.

What ships

  • FbuildError::UnsupportedDeployMethod { board, requested, supported } — structured fields
  • validate_deploy_method(board, requested, &supported) — case-insensitive match, trim/lowercase on both sides, empty supported is a config-bug surface
  • default_deploy_method(&supported) — first entry, matches PlatformIO's upload.protocol convention

Tests — 11 passed

Supported acceptance, unsupported rejection with structured fields, case-insensitive matching from board JSON, LPC845-BRK / ESP32 / Teensy / RP2040 worked examples, empty supported, default picker.

Out of scope (follow-up)

Wiring validate_deploy_method into each Deployer's pre-deploy hook + board JSON lookup — needs the board JSON parser to expose upload.protocols on the relevant struct.

Closes#692.

Summary by CodeRabbit

Release Notes

  • Improvements
    • Enhanced validation of deployment methods with clearer error reporting that indicates which upload protocols are supported for your board.

#692. Pre-deploy guard against picking an unsupported
upload_protocol — today's failure mode is a 30-180 s backend timeout
that doesn't say 'this board doesn't do OTA'. Now it fails fast with
a structured error naming the supported alternatives.
- FbuildError::UnsupportedDeployMethod { board, requested, supported }
— structured fields so CI / bash autoresearch can pinpoint the
mismatch without parsing strings
- fbuild_deploy::method_validation::validate_deploy_method(board,
requested, &supported) — case-insensitive match, trim/lowercase on
both sides, empty supported is a config-bug surface (not silent
fallback)
- default_deploy_method(&supported) — first entry, matches
PlatformIO's upload.protocol convention
- 11 unit tests covering: supported acceptance, unsupported rejection
with structured fields, case-insensitive matching from board JSON,
LPC845-BRK / ESP32 / Teensy / RP2040 worked examples, empty
supported, default picker.
Out of scope (follow-up): wiring validate_deploy_method into each
Deployer's pre-deploy hook + board JSON lookup — needs the board
JSON parser to expose upload.protocols on the relevant struct.
Closes#692.
@coderabbitai

coderabbitaiBot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4405253c-0c06-4278-84ea-0b9a283924c3

📥 Commits

Reviewing files that changed from the base of the PR and between b480b22 and 638155d.

📒 Files selected for processing (3)
  • crates/fbuild-core/src/lib.rs
  • crates/fbuild-deploy/src/lib.rs
  • crates/fbuild-deploy/src/method_validation.rs

📝 Walkthrough

Walkthrough

Adds a new UnsupportedDeployMethod variant to FbuildError with board, requested, and supported fields. Introduces a method_validation module in fbuild-deploy exporting validate_deploy_method (case-insensitive matching with normalization) and default_deploy_method (returns first supported entry), plus unit tests.

Changes

Deploy Method Validation

Layer / File(s)Summary
UnsupportedDeployMethod error variant
crates/fbuild-core/src/lib.rs
Adds UnsupportedDeployMethod { board: String, requested: String, supported: String } to FbuildError with a formatted #[error(...)] message reporting all three fields.
validate_deploy_method and default_deploy_method
crates/fbuild-deploy/src/lib.rs, crates/fbuild-deploy/src/method_validation.rs
Exports the new method_validation submodule; adds module docs and implements validate_deploy_method (trims/lowercases requested, rejects empty supported list, case-insensitive match, returns error with comma-separated alternatives on mismatch) and default_deploy_method (returns first supported entry or None).
Unit tests
crates/fbuild-deploy/src/method_validation.rs
Covers acceptance, structured error field assertions, case-insensitive board JSON and requested method handling, empty-supported-list rejection with placeholder text, default method selection, and whitespace/uppercase normalization.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit hops in, checks the board's allowed list,
If your protocol's missing — you won't be missed!
esptool? cmsis-dap? Let's see what you've got,
Trim it, lowercase it, match or it's not.
Fail fast, friend! No more mysterious hang —
The error speaks clearly with a satisfying clang. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately summarizes the main change: introducing per-board deploy method validation with fail-fast behavior to address unsupported protocol selection.
Linked Issues check✅ PassedThe PR implements all core requirements from issue #692: the new error type carries structured fields, validate_deploy_method performs case-insensitive matching with trimming, default_deploy_method returns first supported entry, and empty supported lists are treated as configuration bugs.
Out of Scope Changes check✅ PassedAll changes are directly scoped to the validation logic: new FbuildError variant, method_validation module with two public functions, and comprehensive tests. No unrelated changes present.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/692-deploy-method-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 7b79c2e into mainJun 20, 2026
85 of 91 checks passed
@zackees
zackees deleted the feat/692-deploy-method-validation branch June 20, 2026 20:58
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fbuild-deploy: enumerate supported deploy protocols per board; fail fast on unsupported

1 participant

@zackees