Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃獰 馃Ч Match sync catalog items by name and namespace, not their index #20387

Merged
merged 2 commits into from
Dec 13, 2022

Conversation

teallarson
Copy link
Contributor

@teallarson teallarson commented Dec 12, 2022

What

Match by stream name and namespace instead of by syncCatalog index.

Fixes a bug when editing a connection where adding or removing a stream from the source, refreshing the source schema, then canceling the changes in the form would throw an error in <CatalogTree/>

How

Name and namespace are more stable matchers than index. The array may change based on refreshes, making it not a stable reference.

@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Dec 12, 2022
@teallarson teallarson changed the title match by name and namespace, not index 馃獰 馃Ч Match sync catalog items by name and namespace, not their index Dec 12, 2022
@teallarson teallarson marked this pull request as ready for review December 12, 2022 20:55
@teallarson teallarson requested a review from a team as a code owner December 12, 2022 20:56
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

The solution looks correct, but the code can be streamlined

return stream.config?.selected !== initialValues.syncCatalog.streams[idx].config?.selected;
streams.filter((stream) => {
const matchingInitialValue = initialValues.syncCatalog.streams.find(
(initialStream) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also match by id (which is the stringified index of the item in the array) a little higher up, and in the BulkEditService. TBD whether those should also be changed to use name & namespace as matchers. I am unsure if either would get called in a case where using the index would be unreliable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same thought as well when I was looking at this. I wonder if we can trust the ID, but in this solution we know we can trust name + namespace as a matching criteria so this is less risky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it's worth making a ticket to audit other uses of index/stream id? I'm not sure they're a problem, but I'm not sure they're not a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's good to track this in a ticket. If the id proves to be trustworthy, we can simplify a lot of checks in our code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ope. I hit merge. The id is the item's index in the array converted to a string, so it would presumably have the same problems.

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

So fresh and so clean

return stream.config?.selected !== initialValues.syncCatalog.streams[idx].config?.selected;
streams.filter((stream) => {
const matchingInitialValue = initialValues.syncCatalog.streams.find(
(initialStream) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same thought as well when I was looking at this. I wonder if we can trust the ID, but in this solution we know we can trust name + namespace as a matching criteria so this is less risky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants