Skip to content

feat: id validation#404

Open
azfoo wants to merge 2 commits intodevfrom
id-validation
Open

feat: id validation#404
azfoo wants to merge 2 commits intodevfrom
id-validation

Conversation

@azfoo
Copy link
Collaborator

@azfoo azfoo commented Mar 17, 2026

also removes scanning through all of the current ids if no id is given.

@azfoo azfoo requested a review from FelipeDefensor March 17, 2026 22:34
Copy link
Collaborator

@FelipeDefensor FelipeDefensor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clear improvement over my implementation. The only thing, apart from the comments, is that I am not sure we want to silently "adjust" conflicting IDs in the long term. A user might, for instance, write a script that creates a components with a hardcoded ID, and later use that ID to get the component for a future operation. That operation would misteriously fail if we changed the ID when creating the component without an error or warning. Since we are rather far from such an API in the moment, I am fine with going for what you propose, at least for now.

next_id = next(self._id_counter)
return str(next_id)
if int_id in existing_ids:
return str(next(self._id_counter))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next(self._id_counter) might already be in existing_ids, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, see test_create_component_with_higher_id_before_lower_id. self._id_counter always increments from the largest input id, so there's no way it'll be smaller.

Comment on lines +300 to +301
if not existing_ids or int_id > max(existing_ids):
self._id_counter = itertools.count(int_id + 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better than what we had.

Base automatically changed from refactor-timeline-requests to dev March 20, 2026 12:28
azfoo added 2 commits March 20, 2026 18:28
also removes scanning through all of the current ids if no id is given.
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.

2 participants