apache / apache/iggy

(Rust SDK) IggyStream API has unintentional behavior: can create one topic and read from another

Open
#4,155 0 comments 0 reactions 1 assignee Claimed by @haubur View on GitHub
bug
Dominant language
Rust
Stars
4.9k
Forks
432
Avg merge
2d 10h
Merged PRs (30d)
173

Description

### Bug description

`IggyConsumerConfig` allows to set both `stream_name`, `topic_name` AND `stream_id`, `topic_id`.

The 'id's are of type `Identifier` and usually derived/ generated from the `name` strings.
So they have a one to one mapping. Internally, streams and topics are identified via `id`s.

If a `IggyConsumerConfig` sets both individually (not matching) calling `build` calls
https://github.com/apache/iggy/blob/2019e145d66620e1f364e4966b8ac237f981b2a5/core/sdk/src/stream_builder/build/build_stream_topic.rs#L52-L65
potentially adding a new stream/ topic from the id, while the consumer's `init()` call binds the consumer derives the topic/stream_id to connect to from the `stream_name`, `topic_name`. Potentially, binding to another stream/topic compared to the one previously configured on the server.

**Proposed fix (breaking API change):** Remove `id`s from public API surface.

---

One nit, that I would like to subsume here:
`IggyStreamConfig` holds both `IggyConsumerConfig` and `IggyProducerConfig` but methods such as `stream_name` etc. always return the names from the producer config, even though consumer and producer configs can point to different stream/ topics.

**Proposed fix:** Remove methods from IggyStreamConfig, they are callable from IggyConsumerConfig and IggyProducerConfig already.

### Affected area / component

_No response_

### Deployment

None

### Versions

_No response_

### Hardware / environment

_No response_

### Sample code

_No response_

### Logs

_No response_

### Iggy server config

_No response_

### Reproduction

_No response_

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.