Conversation
…an instance Honours the includeDueBefore, includedDataValues and includedPresentationTexts settings in copyInstanceSettings in applicationmetadata.json. The settings were added to CopyInstanceSettings in Altinn.Platform.Storage.Interface 4.7.2, which this change updates to. Both the legacy copy endpoint and the simplified instantiation endpoint with sourceInstanceId honour the settings. Listed data values and presentation texts are copied from the source instance after the form data has been copied, so they take precedence over values derived from dataFields and presentationFields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation consistently covers both copy paths and includes appropriate automated verification.
Review effort: Balanced
Findings: None
What changed in this PR
Adds configurable copying of due dates, selected data values, and presentation texts for both instance-copy endpoints.
Changes:
- Adds copy settings via Storage Interface 4.7.2.
- Copies configured metadata with request due dates taking precedence.
- Adds unit, integration, deserialization, and OpenAPI coverage.
| File | Description |
|---|---|
Directory.Packages.props |
Updates the Storage Interface dependency. |
src/Altinn.App.Api/Controllers/InstancesController.cs |
Implements configured metadata copying. |
test/Altinn.App.Api.Tests/Controllers/InstancesController_CopyInstanceTests.cs |
Tests legacy copy behavior. |
test/Altinn.App.Api.Tests/Controllers/InstancesController_PostNewInstanceTests.cs |
Tests simplified endpoint copying end-to-end. |
test/Altinn.App.Core.Tests/Internal/App/AppMetadataTest.cs |
Tests settings deserialization. |
test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/copy-instance-settings.applicationmetadata.json |
Provides metadata test data. |
test/Altinn.App.Api.Tests/OpenApi/OpenApiSpecChangeDetection.SaveJsonSwagger.verified.json |
Updates the JSON OpenAPI snapshot. |
test/Altinn.App.Api.Tests/OpenApi/OpenApiSpecChangeDetection.SaveCustomOpenApiSpec.verified.json |
Updates the custom OpenAPI snapshot. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…e instance Storage accepts presentationTexts on instance creation since Altinn/altinn-storage#1129, and has always accepted dataValues. Setting the included values on the instance template removes the separate UpdateDataValues and UpdatePresentationTexts calls after the copy. Values derived from dataFields and presentationFields are calculated after the form data is copied, so they now win over the copied values for overlapping keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opying The simplified instantiation test now runs with and without dueBefore in the copy request, and asserts that the request value wins over the source instance. It also lists a presentation text derived from presentationFields in includedPresentationTexts, with a stale value on the source, and asserts that the copy gets the value recalculated from the copied form data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/publish |
PR release:
|

When an instance is copied today,
dataValues,presentationTextsanddueBeforeare not carried over from the source instance. Apps that set data values from code (for example anappVersionvalue that anICopyInstanceValidatorchecks) lose those values on the first copy, so a copy of a copy can no longer be validated.This PR adds three settings to
copyInstanceSettingsinapplicationmetadata.json:includeDueBeforebooldueBeforefrom the source instance. Defaults tofalse. On the simplified instantiation endpoint, adueBeforegiven in the request takes precedence.includedDataValuesstring[]dataValuesto copy from the source instance.includedPresentationTextsstring[]presentationTextsto copy from the source instance.Keys that do not exist on the source are ignored. If a key is also derived from
dataFields/presentationFields, the value recalculated from the copied form data is used.Implementation notes
CopyInstanceSettingsin feat: add settings for copying due date, data values and presentationtexts altinn-storage#1121 (backported to the v4 interface line). This PR updatesAltinn.Platform.Storage.Interfacefrom 4.7.1 to 4.7.2, which contains them, so no app specific model is needed./legacy/instances/{partyId}/{guid}/copyendpoint and the simplifiedinstances/createendpoint withsourceInstanceIdhonour the settings. In the simplified endpoint the source instance is now fetched before the instance template is built sodueBeforecan be set on creation (Storage has no endpoint for updating it afterwards). The archived check therefore runs before the instantiation validator instead of after it.presentationTextson creation since feat: accept presentationTexts when creating an instance altinn-storage#1129. Against a Storage without that change, the presentation texts are silently dropped while data values and due date still work. Localtest gets the same change in Altinn/altinn-studio (feat(localtest): accept presentationTexts when creating an instance) and Altinn/app-localtest.CopyInstanceSettingsschema, coming from the package update. The public API of the app libraries is unchanged.Follow-ups
application-metadata.schema.v1.jsonin the monorepo should get the three new properties so Studio validates them. Left out of this PR since this repository is subtree-merged into the monorepo later.Verification
InstancesController_CopyInstanceTestscover the legacy copy endpoint: the instance template sent to Storage has the listed values anddueBefore, unlisted and missing keys are left out, nothing is copied when the settings are absent, and no separateUpdateDataValues/UpdatePresentationTextscalls are made.CopyInstance_SimplifiedEndpoint_CopiesConfiguredValuesFromSourceinInstancesController_PostNewInstanceTestscreates a source instance with a due date and custom data values/presentation texts, archives it, copies it throughinstances/createand asserts the copied instance'sdueBefore,dataValuesandpresentationTexts.AppMetadataTestverifies thatapplicationmetadata.jsonwith the new settings deserializes as expected.Altinn.App.Core.TestsandAltinn.App.Api.Testsrun onnet10.0(only runtime available locally): all tests pass except two pre-existing file-watcher tests (*ReloadsWhenKubernetesDataSymlinkChanges) that time out in this sandbox and are unrelated to this change.net8.0was not run locally.dotnet csharpier checkpasses.🤖 Generated with Claude Code