-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed reverted PR: Choose optimal sync modes by default on UI #12770
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does seem to preserve sync settings now! 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this by creating a new connection and editing the sync modes in the connection.
}); | ||
|
||
const supportedSyncModes = streamNode.stream.supportedSyncModes; | ||
export const calculateInitialCatalog = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is resolving the initial schema, not necessarily calculating the initial catalog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, that also confused me.
As I understood(if we look at the comments I removed) sometimes we can get supportedSyncModes: []
That's why we need to check the edit and creation modes supportedSyncModes.
I don't know how we can get empty supportedSyncModes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
airbyte-webapp/src/views/Connection/ConnectionForm/formConfig.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes 👍🏼
): SyncSchema => ({ | ||
streams: schema.streams.map<SyncSchemaStream>((apiNode, id) => { | ||
const nodeWithId: SyncSchemaStream = { ...apiNode, id: id.toString() }; | ||
const nodeStream = verifySupportedSyncModes(nodeWithId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place I am still a tiny bit concerned around. This method could change the existing Sync Mode when opening a connection in edit mode, if the previously set sync mode isn't available anymore. In that case the user would see a different sync mode in the UI, than the DB actually has, and also they would not be able to save it(??) because it's still the default values of the form?
@sherifnada Is there any case were a connector (e.g. due to an update) could lose a sync mode on an existing/saved connection's stream that was earlier supported? Is this something we'd need to cater for int he UI, or should that anyway never happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any case were a connector (e.g. due to an update) could lose a sync mode on an existing/saved connection's stream that was earlier supported?
This is not defined behavior but I can't think of a case where there would be a good reason this edge case is needed. Is it possible to explicitly throw an error if that happens, or just leave it empty so the user has to fill it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is nothing we anticipate happening, I'd suggest we simply leave it empty and force the user to select a new one. @dizel852 Do you think we could still change that logic not to jump to full refresh overwrite if the actual configured sync doesn't exist, but leave the select box empty and invalid and force the user to select? (And ideally also add a unit test case for that scenario :D) Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timroes Yes, we can omit supportedSyncMode
checking for edit mode.
But what should we verify it in creation
mode?
If we will leave supportedSyncMode
checking just for creation we will get a behavior:
https://www.loom.com/share/062406b7dd26417580a914ec6ffef0c6
As you can see, available sync modes rely on at least one (or default) value in 'supportedSyncMode'.
IMO One of the solutions - does not verify supportedSyncMode
at all, neither in creation
nor edit
modes.
Do we get empty empty supportedSyncMode
? - Okay, that means that our connection form is invalid since there are no available sync modes. So we just do not allow the user to create a connection.
Advantages: We don't try somehow fix the backend's response. Another question is why do we get such a response?
Disadvantages: More fixes 😅 Need to update our form validations and tests.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dizel852 I agree with the part: that we should not try to fix a broken connector (like the end-2-end one) in the FE by overwriting it's available sync modes. I think we should simply not adjust them, and in this case not being able to create a connection with that connector. Otherwise we'd allow users to create a connection with a configuration the backend told us is invalid, which does not sound like a good idea.
Despite being more work I think we should make sure that we error the form in this case, i.e. allow for an undefined
value in case there is no valid syncCode, check for that in our validation code, and make sure we're setting undefined
if there's no valid configuration (either in getOptimalSyncMode
or rather add another method call to calculateInitialCatalog
for that.
With that said, we should still make sure our end-to-end testing connectors will not result in an invalid configuration that other connectors in practise can't end up. @sherifnada would you maybe able to take that to the connector team? Also if we change the UI here, without fixing the connectors I am not sure if we actually still can run end-to-end tests, thus it would be good if we could solve that somehow in the near future if possible :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite being more work I think we should make sure that we error the form in this case, i.e. allow for an
undefined
value in case there is no valid syncCode, check for that in our validation code, and make sure we're settingundefined
if there's no valid configuration (either ingetOptimalSyncMode
or rather add another method call tocalculateInitialCatalog
for that.
Ok, got it. Will update the implementation. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it locally and looked through the code. Everything seems to be working (creation or editing) for me. I've tested with the GitHub source and postgres destination. I changed some values when creating the connection and validated that editing it, it will still be the same. I have one open question that I pinged Sherif on, that I'd like to get clarified before approving this.
Wondering if we want to hold off on this until this issue is resolved: #12728 |
# Conflicts: # airbyte-webapp/src/views/Connection/ConnectionForm/formConfig.tsx
- fix Type
Finally resolved all merge conflicts 🤪 That was something... @tealjulia If you don't mind, can we merge the PR before #12728 cc: @timroes |
I'm fine with that if it's been tested locally by others! I was more just curious if there might be an interaction between the two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it locally and it works as expected on Connection creation and editing (tested using Github source, changed sync modes, namespace format, turned streams off, etc.). I'm not sure where we're at with the questions above for the Connectors team, and given that this form has been finicky lately, this probably deserves a second approval before merging.
@tealjulia agree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Tested several scenarios, and it seems to work as we agreed on.
…ehq#12770) * Revert "Revert "Choose optimal sync modes by default on UI (airbytehq#12411)" (airbytehq#12583)" This reverts commit 9789ffd. * get optimal sync mode only in creation mode * sort sync mode options by priority * add tests for calculateInitialCatalog * remove duplicated tests * fixed one-line 'if' * move calculationInitialCatalog function to file and export it as default * - fix merge conflicts - fix Type * update tests
What
Revert => Revert "Choose optimal sync modes by default on UI (#12411)" (#12583)
Original description
Closes #9625
Set the optimal sync modes for Source and Destination by default on UI.
How
Choosing the mode by priority:
Incremental(cursor defined) => Append Dedup
Full Refresh => Overwrite
Incremental => Append
Full Refresh => Append