Repository navigation
fix(rmcp): import base64-only prompt content types under the feature - #1314
Conversation
chrikrah
left a comment
There was a problem hiding this comment.
@ragen1337 the warning is real and this removes it. Approve.
non-blocking: no CI job will ever show the difference. Both clippy steps in .github/workflows/ci.yml:62-71 enable base64. The second gets it from the cargo metadata feature list, so -D warnings never sees prompt.rs built without it. A registry or git consumer misses it too, since cargo hands dependencies --cap-lints allow. Who sees it is whoever builds rmcp itself with the feature off, in-tree or as a path dependency. Clear it and CI can one day gate that feature set.
Verification
git archive of 49e3cae into a clean directory, rustc 1.96.1 from the pinned rust-toolchain.toml.
$ cargo check -p rmcp --no-default-features --message-format short
crates/rmcp/src/model.rs:322:19: warning: methods `numeric_string_value` and `matches_response_id` are never used
crates/rmcp/src/model.rs:657:11: warning: associated items `TRANSPORT_CLOSED_MARKER`, ... are never used
warning: `rmcp` (lib) generated 2 warnings
# both of these predate the branch
# crates/rmcp/src/model/prompt.rs restored to ae2f9c9, nothing else touched
$ cargo check -p rmcp --no-default-features --message-format short
crates/rmcp/src/model/prompt.rs:5:15: warning: unused imports: `AudioContent` and `ImageContent`
warning: `rmcp` (lib) generated 3 warnings (run `cargo fix --lib -p rmcp` to apply 1 suggestion)
$ cargo check -p rmcp --all-targets --no-default-features --message-format short
crates/rmcp/tests/test_prompt_routers.rs:74:13: error[E0425]: cannot find function `async_function_prompt_attr` in this scope
error: could not compile `rmcp` (test "test_prompt_routers") due to 19 previous errors
error: could not compile `rmcp` (lib test) due to 4 previous errors
# not run: the test suite, and any build on Windows or macOS
@DaleSeo, a third clippy step would hold this, and it is not green yet. --all-targets does not compile without default features. --lib alone still trips -D warnings on the two model.rs warnings above. Worth gating that feature set after those two?
|
Thanks for checking. The two I have a fix that adds |
|
The MSRV failure isn't from your change. It was fixed on |
49e3cae to
de3fa6f
Compare
|
Rebased onto latest |
DaleSeo
left a comment
There was a problem hiding this comment.
Thanks for the fix, @ragen1337!
`skills.rs` invokes `const_string!`, whose expansion contains a `#[cfg(feature = "schemars")]` impl that names `Cow` unqualified. The import is therefore required only when `schemars` is enabled, and is unused — a `-D warnings` error — without it. CI's reduced-feature clippy matrix (`cargo hack clippy --lib --each-feature --exclude-features local`) hits exactly that combination, which is why the PR's older `ci.yml` never caught it. Gate the import with `#[cfg(feature = "schemars")]` instead of deleting it: removal breaks the `schemars` build (E0425 `cannot find type Cow` in `model.rs:127` via the macro expansion). Verified with CI's exact command locally: cargo hack clippy --package rmcp --lib --each-feature --exclude-features local -- -D warnings `Cow` is no longer reported in either the schemars-on or schemars-off combo. (The remaining `prompt.rs` failure in that matrix is inherited from being behind `main`; upstream modelcontextprotocol#1314 fixes it, so it does not appear on CI's merge commit.)
`skills.rs` invokes `const_string!`, whose expansion contains a `#[cfg(feature = "schemars")]` impl that names `Cow` unqualified. The import is therefore required only when `schemars` is enabled, and is unused — a `-D warnings` error — without it. CI's reduced-feature clippy matrix (`cargo hack clippy --lib --each-feature --exclude-features local`) hits exactly that combination, which is why the PR's older `ci.yml` never caught it. Gate the import with `#[cfg(feature = "schemars")]` instead of deleting it: removal breaks the `schemars` build (E0425 `cannot find type Cow` in `model.rs:127` via the macro expansion). Verified with CI's exact command locally: cargo hack clippy --package rmcp --lib --each-feature --exclude-features local -- -D warnings `Cow` is no longer reported in either the schemars-on or schemars-off combo. (The remaining `prompt.rs` failure in that matrix is inherited from being behind `main`; upstream modelcontextprotocol#1314 fixes it, so it does not appear on CI's merge commit.)
Brings the branch current with modelcontextprotocol/rust-sdk main (was 42 commits behind). Conflict-free per `git merge-tree --write-tree`. Motivation: CI runs clippy/tests on the merge commit, so the branch was already being linted with main's newer, stricter `cargo hack --lib --each-feature` clippy matrix while its own ci.yml lacked that step. Merging makes the local gate match what CI actually runs. Inherited fix included: upstream modelcontextprotocol#1314 (prompt.rs AudioContent/ImageContent unused imports), which is why that error showed in local reduced-feature clippy but never on CI.
ImageContentandAudioContentare only used bynew_image/new_audio, which are behind thebase64feature, so building without it gives an unused-imports warning:Moved the imports into those two functions (same as the
base64imports there) and added them to the test module. No API changes.Checked with clippy
--all-features -D warnings, the prompt tests and fmt.