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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ const CatalogTreeComponent: React.FC<React.PropsWithChildren<CatalogTreeProps>>

const changedStreams = useMemo(
() =>
streams.filter((stream, idx) => {
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.

initialStream.stream?.name === stream.stream?.name &&
initialStream.stream?.namespace === stream.stream?.namespace
);
return stream.config?.selected !== matchingInitialValue?.config?.selected;
}),
[initialValues.syncCatalog.streams, streams]
);
Expand Down