Skip to content

feat(api): CSV/JSON import + export of account_service_overrides #9

Closed

Description

@cristim

Summary

Power users with many accounts and many overrides currently have only the per-row UI (LeanerCloud/cloud-commitments-cli#72/#106) or direct API calls to manage their override state. There's no way to export the current override config (e.g., to back it up, diff against a known-good baseline, or transplant it into a fresh tenant) or to import a desired-state file.

CSV (or JSON / YAML) import/export of account_service_overrides rows would unblock:

  • Disaster recovery — capture override config as-of-now, restore later.
  • Migration between environments (dev → staging → prod) — each environment keeps its own overrides, but a baseline can be cloned.
  • Bulk audit — diff exports across time to see what changed.
  • Bootstrap — a customer with N accounts and consistent override patterns can craft one CSV and import once.

Scope sketch

Export

GET /api/accounts/service-overrides/export.csv (or .json) — returns every override row across all accounts the user has access to, with columns: account_id, account_name, provider, service, enabled, term, payment, coverage, ramp_schedule, include_engines, exclude_engines, include_regions, exclude_regions, include_types, exclude_types, created_at, updated_at.

Frontend: a button in Settings → Accounts (or a dedicated "Export overrides" link) that triggers a download.

Import

POST /api/accounts/service-overrides/import accepting the same schema. Behaviour:

Frontend: a file-picker + dry-run mode (preview which rows would be inserted/updated/no-op) before actual apply.

Concerns

Recommendation

Defer until a customer specifically requests it. The export side is cheaper than import and could ship first (read-only, no validation complexity). Import follows when there's clear demand.

Acceptance criteria (when prioritised)

Out of scope

  • CSV import for service_configs (global defaults). Different use case — the global config is one row per (provider, service), so the diff-patch story is much simpler.
  • API-side bulk apply (already possible by N parallel PUT calls).

Activity

  1. cristim commented on Apr 28, 2026

    @cristim
    MemberAuthor

    P3: the issue body itself recommends deferring until a customer requests it. Export is cheaper to ship first (read-only), but neither side is blocking active feature delivery. The account-id portability concern makes import genuinely complex (L effort). (triage agent wave1-C)

  2. IAmJSD commented on Oct 26, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  3. cristim commented on Nov 12, 2026

    @cristim
    MemberAuthor

    Verified on origin/main 447a98b: export and import of account_service_overrides is met.

    • Export (JSON and ?format=csv): internal/api/handler_override_transfer.go, route router.go:284, openapi.yaml:4561; CSV round-trip tested in handler_override_transfer_test.go:178.
    • Import with strict and best_effort modes, dry_run, per-row report: internal/api/handler_override_import.go:33-120, route router.go:285, openapi.yaml:4599.
    • Cross-tenant reconciliation by provider + account_external_id: handler_override_import.go:89-93, test handler_override_import_test.go:56.
    • Validity rules shared with service config; rejection tests at handler_override_import_test.go:105,119,259.
    • Audit events per imported row: handler_override_audit_test.go:85, handler_override_audit_integration_test.go:140.
    • UI: frontend/src/modules/override-transfer.ts (file picker, dry-run preview, apply).
    • Landed in b0972e3 (feat(accounts): export and import account service overrides, feat(accounts): export and import account service overrides #1486).
      Closing as completed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions