Skip to content

feat: register import auto-create-or-fail-clearly (#1487)#2056

Merged
rubenvdlinde merged 1 commit into
developmentfrom
wip/build-register-import-auto-create
Jul 24, 2026
Merged

feat: register import auto-create-or-fail-clearly (#1487)#2056
rubenvdlinde merged 1 commit into
developmentfrom
wip/build-register-import-auto-create

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Summary

  • ImportService::importFromJson() threw a bare "requires a specific schema" error whenever the target register did not exist (Register import workflow: auto-create register from JSON or fail clearly #1487) — a register bundle (register + schemas + objects) could never be moved into an instance that lacked the register.
  • When the caller cannot resolve the target register by slug, the payload is now checked for a register-bundle envelope (components.registers + components.schemas, the same shape ConfigurationService::importFromApp() understands): a bundle auto-creates the register + schemas by reusing ImportHandler::importRegister()/importSchema() (no duplicated creation logic, ADR-011), then imports the bundle's objects; re-import is idempotent (both methods look the register/schema up by slug first).
  • A payload that is not a creatable bundle now fails with a RegisterNotFoundException naming the missing slug and the two remedies (create the register first, or supply a full bundle) — the controller's existing catch-all maps this to an actionable 400, never a 500.
  • RegistersController::import() no longer 404s immediately on a missing register; a JSON upload from an admin is let through (register: null) so the bundle can auto-create — every other case (non-admin, or a non-JSON/non-bundle upload) keeps the existing 404.

Implements openspec/changes/register-import-auto-create (REQ-IMP-AC-01/02/03), archived in this PR.

Test plan

  • ImportServiceRegisterAutoCreateTest: bundle for a non-existent register → register + schema created, object imported; re-import → no duplicate register (createFromArray asserted once()); plain object list for a missing register → clear error naming the slug, 4xx-range code.
  • RegistersControllerTest: admin + JSON register-bundle for a missing register passes through to the importer; non-admin same request still 404s; non-JSON (Excel) upload for a missing register still 404s unchanged.
  • Full existing ImportService/ImportHandler/RegistersController unit suites pass locally (nextcloud:34.0.0-apache container, PHPUnit) with no regressions (verified against an unmodified origin/development baseline — identical pre-existing failure count in both).
  • phpcs/phpmd clean on all three changed lib/ files.
  • openspec validate --all --strictspec/data-import-export passes; no new failures introduced.

Note: this repo's CI has known pre-existing infra failures (npm lockfile, eslint/stylelint/license, Newman) unrelated to backend PHP changes.

ImportService::importFromJson() threw a bare "requires a specific
schema" error whenever the target register did not exist, silently
blocking a common onboarding flow: moving a register bundle (register
+ schemas + objects) between instances.

Now, when the caller cannot resolve the target register by slug:
- a register-bundle payload (components.registers + components.schemas,
  the same envelope ConfigurationService::importFromApp() understands)
  auto-creates the register and its schemas by reusing
  ImportHandler::importRegister()/importSchema() — no duplicated
  creation logic — then imports the bundle's objects into it;
- re-importing an existing bundle is idempotent (both methods look the
  target up by slug before creating);
- anything else fails with a RegisterNotFoundException naming the
  missing slug and the two remedies, mapped to a 4xx by the controller.

RegistersController::import() no longer 404s immediately on a missing
register; a JSON upload from an admin is let through (register: null)
so the bundle can be auto-created — every other case (non-admin, or a
non-JSON upload) keeps the existing 404.

Closes #1487.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 402ab62

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 172/172
npm
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-07-23 22:08 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 531e2c0 into development Jul 24, 2026
15 of 24 checks passed
@rubenvdlinde
rubenvdlinde deleted the wip/build-register-import-auto-create branch July 24, 2026 05:42
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