xalestar opened a new issue, #4767:
URL: https://github.com/apache/iggy/issues/4767
### Bug description
Deleting a personal access token that does not exist, over the binary
protocol, fails with code 20 as expected, but the error message has an empty
key:
```
Resource with key: was not found.
```
The caller cannot tell from the message what was not found. I expected the
message to name the resource, or at least not to print an empty placeholder.
By reading the code, not confirmed for every path: the binary response
carries only the status code, and the client rebuilds the error with
`IggyError::from_code` (`core/common/src/error/iggy_error.rs:703`), which calls
`from_repr`. That fills the `String` field of `ResourceNotFound(String)` with
an empty string, and the `#[error("Resource with key: {0} was not found.")]`
format then prints nothing for `{0}`. The server maps
`DeletePersonalAccessTokenResult::NotFound` to code 20
(`core/metadata/src/stm/result.rs:766`), and the user-not-found results use the
same code, so I expect those to show the same message. Other variants with
fields that are decoded from a bare code may have the same problem.
### Affected area / component
Rust SDK, Python SDK, Wire protocol / API
### Deployment
Local build, `cargo run --bin iggy-server -- --with-default-root-credentials`
### Versions
Server: master at 06cf04e5e. Python SDK: branch of #4766, which adds
`delete_personal_access_token` to the Python client.
### Hardware / environment
macOS, Apple Silicon (arm64)
### Sample code
```python
import asyncio
from apache_iggy import IggyClient
async def main():
client = IggyClient("127.0.0.1:8090")
await client.connect()
await client.login_user("iggy", "iggy")
try:
await client.delete_personal_access_token("no-such-token-xyz")
except Exception as error:
print(type(error).__name__, error.code, error)
asyncio.run(main())
```
Output:
```
IggyError 20 Resource with key: was not found.
```
### Reproduction
1. Start a local server with `cargo run --bin iggy-server --
--with-default-root-credentials`.
2. Build the Python SDK from #4766 with `maturin develop` in
`foreign/python`. The Rust client's `delete_personal_access_token` goes through
the same `from_code` path.
3. Run the sample above.
--
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]