-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
fix: import duplicate features #4550
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@@ -108,6 +108,10 @@ const useAPI = ({ | |||
const response = await res.json(); | |||
if (response?.details?.length > 0 && propagateErrors) { | |||
const error = response.details[0]; | |||
setErrors(prev => ({ |
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 was missign before. When unknown error was triggered the errors Record was empty. Code that depended on errors being populated (last import stage) failed because of this check missing.
@@ -29,6 +29,11 @@ export const useImportApi = () => { | |||
}); | |||
return res; | |||
} catch (e) { | |||
trackEvent('export_import', { |
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.
added extra tracking for failed imports so that we know when it happens
@@ -289,8 +290,16 @@ export default class FeatureToggleStore implements IFeatureToggleStore { | |||
return this.rowToFeature(row[0]); | |||
} catch (err) { | |||
this.logger.error('Could not insert feature, error: ', err); | |||
if ( |
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.
when we create feature and SQL fails we should not fail silently and return undefined. We want to get instant feedback from code that something was wrong where the failure happened
typeof err.detail === 'string' && | ||
err.detail.includes('already exists') | ||
) { | ||
throw new NameExistsError( |
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.
special case for duplicate errors
@@ -348,10 +348,21 @@ export default class ExportImportService { | |||
); | |||
} | |||
|
|||
private async createToggles(dto: ImportTogglesSchema, user: User) { | |||
private async createOrUpdateToggles(dto: ImportTogglesSchema, user: User) { |
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.
we had a bug in the previous import that you couldn't update toggles themselves. So e.g. if you changes toggle type in import it was ignored.
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.
Now we detect if feature exists and update it if needed. I wanted to put this code into the feature toggle service itself bu we need createOrUpdate within a project not a global createOrUpdate in any project so for now I decided to leave createOrUpdate in the import subdomain.
@@ -10,7 +10,9 @@ export const isValidField = ( | |||
if (!matchingExistingField) { | |||
return true; | |||
} | |||
return importedField.legalValues.every((value) => | |||
matchingExistingField.legalValues.find((v) => v.value === value.value), | |||
return (importedField.legalValues || []).every((value) => |
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.
fixing typechecker errors with legalValues being undefined
@@ -2,11 +2,11 @@ import { Store } from './store'; | |||
|
|||
export interface IContextFieldDto { | |||
name: string; | |||
description?: string; | |||
description?: string | null; |
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.
fixing typechecked errors
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.
LG
About the changes
Important files
Discussion points
Next PR will also add validation state checking for duplicates.
Separate PR in the enterprise codebase soon.