Skip to content

fix(knowledge): show platform-accurate valid options in embedding type error#3722

Open
sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev:fix/knowledge-linux-arm-error-message
Open

fix(knowledge): show platform-accurate valid options in embedding type error#3722
sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev:fix/knowledge-linux-arm-error-message

Conversation

@sandikodev
Copy link
Copy Markdown

@sandikodev sandikodev commented Apr 4, 2026

Issue

Closes #3139

Problem

On Linux ARM64, EmbeddingType::Best is not available — the candle module is excluded via #[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]. When a user passes --index-type best on that platform, from_str correctly returns None, but the error message was misleading:

Invalid embedding type 'best'. Valid options are: fast, best

best is listed as a valid option but is not accepted on that platform, causing user confusion (as reported in the issue).

Fix

Use cfg to build the valid options string at compile time:

#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
let valid = "fast";
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
let valid = "fast, best";
return Err(format!("Invalid embedding type '{}'. Valid options are: {}", s, valid));

On Linux ARM64 the error now reads:

Invalid embedding type 'best'. Valid options are: fast

Testing

# Run the targeted test
cargo test -p chat_cli invalid_embedding_type

# Run the full test suite to check for regressions
cargo test -p chat_cli

The test invalid_embedding_type_error_does_not_mention_best_on_linux_arm uses cfg to assert platform-specific behaviour:

  • On Linux ARM64: EmbeddingType::from_str("best") returns None and the error message does not mention best
  • On other platforms: EmbeddingType::from_str("best") returns Some (no change in behaviour)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…e error

On Linux ARM64, EmbeddingType::Best is not available (candle is excluded
via cfg). When a user passes --index-type best on that platform, from_str
returns None and the error message was:

  Invalid embedding type 'best'. Valid options are: fast, best

This is misleading — 'best' is listed as valid but is not accepted.

Use cfg to build the valid options string at compile time so Linux ARM64
shows only 'fast', while other platforms show 'fast, best'.

Fixes aws#3139
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.

bug: knowledge add index-type best failing on linux

1 participant