haubur opened a new issue, #4274:
URL: https://github.com/apache/iggy/issues/4274

   ### Bug description
   
   Relates to #4155 and discussed in #4249 
   
   **Situation**
   On HTTP transport sending `Identifiers` does not carry `IdKind` info.
   
   **Problem**
   The HTTP client sends ids through `as_cow_str()`, and the server parses path 
ids with `from_str_value()`, which tries u32 first. A digit-only name is then 
interpreted as an id instead of a name, which e.g binds consumers to no stream 
(not found) or another stream (with that id).
   
   **Solution**
   The HTTP API needs a way to differentiate between `IdKind`s (numeric and 
string).
   
   Currently failing integration tests 
[here](https://github.com/haubur/iggy/blob/fix/http-handling-identifiers/core/integration/tests/server/http_identifier_kinds.rs).
   
   
   ### Affected area / component
   
   Rust SDK
   
   ### Deployment
   
   None
   
   ### Versions
   
   _No response_
   
   ### Hardware / environment
   
   _No response_
   
   ### Sample code
   
   _No response_
   
   ### Logs
   
   _No response_
   
   ### Iggy server config
   
   _No response_
   
   ### Reproduction
   
   **Three integration tests 
[here](https://github.com/haubur/iggy/blob/fix/http-handling-identifiers/core/integration/tests/server/http_identifier_kinds.rs)**
   
   One example pasted for convenience:
   ```rust
   use iggy::prelude::*;
   use integration::iggy_harness;
   
   const DIGITS_ONLY_NAME: &str = "424242";
   
   #[iggy_harness(test_client_transport = [Tcp, Http])]
   async fn 
given_digit_only_stream_name_when_getting_the_stream_should_resolve_it_by_name(
       harness: &TestHarness,
   ) {
       let client = harness.root_client().await.unwrap();
   
       let created = client.create_stream(DIGITS_ONLY_NAME).await.unwrap();
       let stream_id = Identifier::named(DIGITS_ONLY_NAME).unwrap();
   
       // Should get the correct stream by casting the name into an Identifier.
       // If it fails, the server casts the the digit only name into an 
Identifier with IdKind::Numeric
       // and looks for that id rather the name.
       let fetched = client
           .get_stream(&stream_id)
           .await
           .unwrap()
           .unwrap_or_else(|| {
               panic!(
                   "stream named {DIGITS_ONLY_NAME} must resolve by name, \
                    not as id {DIGITS_ONLY_NAME}"
               )
           });
   
       assert_eq!(fetched.name, DIGITS_ONLY_NAME);
       assert_eq!(fetched.id, created.id);
   }
   ```
   
   ### Contribution
   
   - [x] I'm willing to submit a pull request to fix this bug
   
   ### Good first issue
   
   - [ ] I think this could be a good first issue for a new contributor


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to