Skip to content

Fix/df 1126 update metadata no draft + remove versions array#821

Merged
jbarnsley10 merged 10 commits into
mainfrom
fix/df-1126-update-metadata-no-draft
Jul 9, 2026
Merged

Fix/df 1126 update metadata no draft + remove versions array#821
jbarnsley10 merged 10 commits into
mainfrom
fix/df-1126-update-metadata-no-draft

Conversation

@jbarnsley10

@jbarnsley10 jbarnsley10 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
  • Allows metadata to be changed even if no draft form definition
  • Removes versions array from form metadata
  • Runs a migration to remove versions from all metadata

@jbarnsley10 jbarnsley10 changed the title Fix/df 1126 update metadata no draft Fix/df 1126 update metadata no draft + remove versions array Jun 22, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@alexluckett alexluckett left a comment

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.

I can't see the code relevant to "Allows metadata to be changed even if no draft form definition" - can you point me to it please?

Comment thread src/messaging/publish.js
* @param {FormMetadata} metadata
* @param {FormMetadata} oldMetadata
*/
export async function publishFormOfflineUpdatedEvent(metadata, oldMetadata) {

@alexluckett alexluckett Jul 8, 2026

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.

intentionally removed? changes to "offline" auditing seem out of scope of this PR?

@jbarnsley10 jbarnsley10 Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Realised it was unused code. The audit event is still published but not via this method. I made a slight change to the auditing for the 'take offline'. Arguably this should have been done in a separate PR so as not to pollute things here.

@jbarnsley10

Copy link
Copy Markdown
Contributor Author

When attempting to make a metadata change when no draft (e.g. changing the contact details) gives this stack trace:

Error: Form definition with ID '6a39514a8c9c0c8298c3487e' not found
              at Module.get (file:///Users/work/Projects/DXT/forms-manager/src/api/forms/repositories/form-definition-repository.js:189:18)
              at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
              at async createVersionInTransaction (file:///Users/work/Projects/DXT/forms-manager/src/api/forms/service/versioning.js:60:17)
              at async createFormVersion (file:///Users/work/Projects/DXT/forms-manager/src/api/forms/service/versioning.js:41:20)
              at async handleMetadataVersioning (file:///Users/work/Projects/DXT/forms-manager/src/api/forms/service/index.js:122:5)
              at async file:///Users/work/Projects/DXT/forms-manager/src/api/forms/service/index.js:236:9

The fix in this PR is here https://github.com/DEFRA/forms-manager/pull/821/changes#diff-b9a0e6e2b5e2bab613dd6e8d0b78f6c655680f622eb6af7d8ab402ea90cb5edaL236 which no longer versions the change (which tries to access the draft definition - which doesn't exist).

@jbarnsley10
jbarnsley10 merged commit 14d805b into main Jul 9, 2026
12 checks passed
@jbarnsley10
jbarnsley10 deleted the fix/df-1126-update-metadata-no-draft branch July 9, 2026 09:39
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.

2 participants