Skip to content

[ENG-12678] Unable to submit a project to a collection after editing any section - #1105

Merged
brianjgeiger merged 2 commits into
CenterForOpenScience:feature/pbs-26-22from
sh-andriy:fix/ENG-12678
Nov 19, 2026
Merged

brianjgeiger merged 2 commits into
CenterForOpenScience:feature/pbs-26-22from
sh-andriy:fix/ENG-12678

Conversation

@sh-andriy

@sh-andriy sh-andriy commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Submitting a project to a collection with a CEDAR template failed with "Submitted object must have a published CEDAR metadata record..." after any section was edited. When the Collection Metadata step opened again, the saved answers were loaded with instanceObject, which doesn't rebuild the editor's validity report, so the record was saved as a draft and the submission was rejected. Update on an existing submission had the same issue and switched its published record back to draft.

The CEDAR form on the project, registration and file metadata pages had the same problem: editing a published record and saving it, even without changes, turned it back to draft (ANG-630, ENG-11382). The draft button also showed a raw translation key (ENG-12424).

Summary of Changes

  1. The collection metadata step loads the template and saved answers together with templateAndInstanceObject, so the editor rechecks them.
  2. The metadata page CEDAR form loads the template and saved answers the same way when editing a record, and checks the editor's report again on save.
  3. Added the missing "Save draft" label.
  4. Added templateAndInstanceObject to CedarEditorElement.
  5. Updated unit tests.

Screenshot(s)

n/a

Side Effects

None expected. Incomplete metadata is still saved as a draft and blocked on submit.

QA Notes

Only reproducible with a template that has required fields (test3's Selenium Collection has a required Type, uat1's doesn't).

  1. Open https://test3.osf.io/collections/selenium/add, select a project and complete all steps.
  2. Click "Click to edit" on any section and save the steps again without changing the collection metadata.
  3. Add to Collection, it should go through.
  4. Open an accepted submission with Update and save all steps without changes, its CEDAR record should stay published.
  5. Open a published community metadata record (template with required fields) on a project, registration or file, click Edit and save without changes, it should stay published.
  6. On Add community metadata record, after selecting a template with required fields, the button should say "Save draft".

@brianjgeiger
brianjgeiger requested a review from nsemets November 19, 2026 14:49
@brianjgeiger
brianjgeiger merged commit b1d7ee8 into CenterForOpenScience:feature/pbs-26-22 Nov 19, 2026
3 checks passed
brianjgeiger pushed a commit to CenterForOpenScience/osf.io that referenced this pull request Nov 25, 2026
…12042)

## Ticket
https://openscience.atlassian.net/browse/ENG-12678

## Purpose
QA on test3 couldn't publish a Human Cognitive Neuroscience Data record after editing it. The PATCH returned 500 with `CEDAR metadata does not validate against template "Human Cognitive Neuroscience Data": Additional properties are not allowed ('Dataset instruction text', ...)`.

The CEDAR viewer on the record page adds the template's static fields to the record's `@context`, and the edit form keeps them. Validation already strips extra `@context` keys at the top level, but not in nested elements, and this is the only template with static fields inside elements. Its optional "Data Standard" multiple choice field also has `minItems: 1`, and the editor sends `[]` when nothing is selected, so the record couldn't be published without picking a value.

Before CenterForOpenScience/angular-osf#1105, saving an edited record without changes turned it into a draft, so it wasn't validated.

## Changes
- Strip `@context` keys the template doesn't define in nested elements too. Elements with attribute-value fields keep theirs, the template allows them there.
- `minItems` of a multiple choice field only applies when the field is required.
- PATCH returns 400 with the validation message instead of 500, like create.
- Tests.

## QA Notes
1. Add a Human Cognitive Neuroscience Data record to a project or registration, fill the required fields and leave Data Standard empty, it should be published.
2. Open the record, click Edit and Publish without changes, it should stay published.
brianjgeiger pushed a commit that referenced this pull request Nov 25, 2026
#1109)

- Ticket: https://openscience.atlassian.net/browse/ENG-12678
- Feature flag: n/a

## Purpose
QA on test3 found that editing a published Human Cognitive Neuroscience Data record and saving it without changes turned it into a draft.

Since #1105 the edit form loads the saved answers with `templateAndInstanceObject`, so the CEDAR editor rebuilds its validity report. But cedar-embeddable-editor 1.5.0 doesn't load checkbox answers this way. This template's required "Preprocessing status" is a checkbox, so it came up empty, the record was saved as a draft and that answer was cleared. Loading with `instanceObject` keeps checkbox answers but doesn't rebuild the report, which is what #1105 fixed for the Selenium "Type" field.

## Summary of Changes
1. The metadata page CEDAR form loads the saved answers with `templateAndInstanceObject` and then again with `instanceObject`, so the report is rebuilt and checkbox answers are kept.
2. The collection metadata step does the same.
3. Updated unit tests.

## Side Effects
None expected. A record with a required field left empty is still saved as a draft.

## QA Notes
Human Cognitive Neuroscience Data is the only template with a checkbox field on test3 and prod.

1. Open a published Human Cognitive Neuroscience Data record on a project or registration, click Edit and Publish without changes, it should stay published and "Preprocessing status" should keep its value.
2. Click Edit, uncheck "Preprocessing status" and save, it should be saved as a draft.
3. The #1105 steps should still pass: on https://test3.osf.io/collections/selenium/add, "Click to edit" on Collection Metadata and save without changes, Add to Collection should go through, and Update on an accepted submission should keep its record published.
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.

3 participants