feat: register import auto-create-or-fail-clearly (#1487)#2056
Merged
Conversation
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.
Contributor
Quality Report — ConductionNL/openregister @
|
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.components.registers+components.schemas, the same shapeConfigurationService::importFromApp()understands): a bundle auto-creates the register + schemas by reusingImportHandler::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).RegisterNotFoundExceptionnaming 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 (createFromArrayassertedonce()); 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.ImportService/ImportHandler/RegistersControllerunit suites pass locally (nextcloud:34.0.0-apachecontainer, PHPUnit) with no regressions (verified against an unmodifiedorigin/developmentbaseline — identical pre-existing failure count in both).phpcs/phpmdclean on all three changedlib/files.openspec validate --all --strict—spec/data-import-exportpasses; 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.