Skip to content

Fix duplicate import and gate overwrite/skip on database selection#2964

Open
premtsd-code wants to merge 1 commit intomainfrom
csv-import-upsert
Open

Fix duplicate import and gate overwrite/skip on database selection#2964
premtsd-code wants to merge 1 commit intomainfrom
csv-import-upsert

Conversation

@premtsd-code
Copy link
Copy Markdown
Contributor

Summary

  • Fix duplicate Layout/Typography import in table +page.svelte that caused a Svelte parse error
  • Only show overwrite/skip import options in the migration wizard when Databases resource is selected

Test plan

  • Migration wizard: checkboxes hidden when only Users/Functions/Storage selected
  • Migration wizard: checkboxes visible when Databases is checked
  • CSV import dialog: overwrite/skip checkboxes still work as before

- Merge duplicate Layout/Typography import in table +page.svelte
- Only show overwrite/skip checkboxes in migration wizard when
  Databases resource is selected
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR fixes a duplicate Layout/Typography import parse error in the table page and adds an "Import options" dialog (overwrite / skip) for both CSV imports and the migration wizard, gating the wizard UI behind database resource selection.

  • +page.svelte: Fix is clean — onSelect is now synchronous and stores pending file state, startImport reads that state and properly resets it in finally. trackError is preserved.
  • wizard.svelte: The {#if $formData.databases.root} gate correctly hides the UI when databases is not selected, but importOverwrite and importSkip are plain let variables and are never reset when the user unchecks Databases. If a user enables overwrite, then deselects Databases and submits, overwrite: true is still spread into all four migration API calls — sending unintended flags to the backend.

Confidence Score: 4/5

Safe to merge after fixing the stale import-options state in the migration wizard.

One P1 bug: importOverwrite/importSkip are never cleared when the user unchecks Databases, so stale true values can be spread into migration API calls unexpectedly. The CSV import change in +page.svelte is clean and correct.

wizard.svelte — stale importOverwrite/importSkip state needs to be reset when $formData.databases.root becomes false.

Vulnerabilities

No security concerns identified. The overwrite/skip flags are boolean options passed to an authenticated SDK call; no injection vectors or auth bypass risks are introduced.

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+page.svelte Fixes duplicate import, adds an import-options Dialog (overwrite/skip) before CSV import starts. Logic is clean: onSelect stores pending state, startImport reads it and resets on completion. trackError is preserved.
src/routes/(console)/project-[region]-[project]/settings/migrations/(import)/wizard.svelte Gates the overwrite/skip UI behind database selection, but importOverwrite/importSkip local state is never reset when $formData.databases.root changes back to false — stale values are still spread into all migration API calls.

Reviews (1): Last reviewed commit: "Fix duplicate import and gate overwrite/..." | Re-trigger Greptile

Comment on lines +213 to +236
{#if $formData.databases.root}
<Fieldset legend="Import options">
<Layout.Stack gap="m">
<Selector.Checkbox
size="s"
checked={importOverwrite}
on:change={(e) => {
importOverwrite = e.detail;
if (e.detail) importSkip = false;
}}
label="Overwrite existing documents"
description="Documents with matching IDs will be updated with the imported data." />
<Selector.Checkbox
size="s"
checked={importSkip}
on:change={(e) => {
importSkip = e.detail;
if (e.detail) importOverwrite = false;
}}
label="Skip existing documents"
description="Documents with matching IDs will be silently skipped." />
</Layout.Stack>
</Fieldset>
{/if}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Stale import options sent when databases is deselected

importOverwrite and importSkip are local variables that persist even when the "Import options" fieldset is hidden. If a user:

  1. Selects Databases → enables "Overwrite existing documents" (sets importOverwrite = true)
  2. Then unchecks Databases ($formData.databases.root becomes false)
  3. Finishes the wizard

The importOptions object is still constructed with the stale importOverwrite: true and spread into every migration API call, sending unintended overwrite/skip flags to the backend even though no databases are being migrated.

Reset both values when databases is deselected, e.g. by deriving them reactively:

$: effectiveOverwrite = $formData.databases.root ? importOverwrite : false;
$: effectiveSkip = $formData.databases.root ? importSkip : false;

const importOptions = {
    overwrite: effectiveOverwrite,
    skip: effectiveSkip
};

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.

1 participant