Compilation error: codegen emits the code for optional api version, when it is not
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start with specification/purview/data-plane/datamap and inspect the generated spec/datamap/src/generated/clients/data_map_discovery_client.rs around the api_version declaration and auto_complete method. Trace the code-generation entry point that produces this client, then regenerate the output and compile it to confirm the optional API-version handling is consistent.
Written by the indexing model from the issue text.
Description
This affects specification/purview/data-plane/datamap:
error[E0277]: the trait bound `std::string::String: AsRef<std::option::Option<_>>` is not satisfied
--> spec\datamap\src\generated\clients\data_map_discovery_client.rs:47:53
|
47 | if let Some(api_version) = self.api_version.as_ref() {
| ^^^^^^ the trait `AsRef<std::option::Option<_>>` is not implemented for `std::string::String`
|
= help: the following other types implement trait `AsRef<T>`:
`std::string::String` implements `AsRef<OsStr>`
`std::string::String` implements `AsRef<Path>`
`std::string::String` implements `AsRef<[u8]>`
`std::string::String` implements `AsRef<str>`
when
...
#[tracing::client]
pub struct DataMapDiscoveryClient {
pub(crate) api_version: String, // <-- declared here
pub(crate) endpoint: Url,
pub(crate) pipeline: Pipeline,
}
impl DataMapDiscoveryClient {
...
#[tracing::function("Customizations.Discovery.autoComplete")]
pub async fn auto_complete(
&self,
body: RequestContent<AutoCompleteOptions>,
options: Option<DataMapDiscoveryClientAutoCompleteOptions<'_>>,
) -> Result<Response<AutoCompleteResult>> {
let options = options.unwrap_or_default();
let ctx = options.method_options.context.to_borrowed();
let mut url = self.endpoint.clone();
url.append_path("/search/autocomplete");
let mut query_builder = url.query_builder();
if let Some(api_version) = self.api_version.as_ref() { // <--fails here
query_builder.set_pair("api-version", api_version);
}
...
- Dominant language
- Rust
- Stars
- 7
- Forks
- 11
- Avg merge
- 14h 15m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/typespec-rust
-
CodeGen rust
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Azure/typespec-rust#959 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
Azure/typespec-rust#1032 ·
-
CodeGen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Azure/typespec-rust#1029 ·
-
CodeGen
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Azure/typespec-rust#1028 ·
-
CodeGen
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Azure/typespec-rust#1020 ·
All issues in Azure/typespec-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100