Skip to content

Conversation

@Saixel
Copy link
Contributor

@Saixel Saixel commented Mar 6, 2025

This PR restores the previous changes for metadata block handling in #11224 that were reverted, and addresses the test failures that led to the revert. The changes include:

  • Restore of the original metadata block changes
  • Investigation and fix of the test failures
  • Analysis of the displayOnCreate field behavior in metadata blocks

See #11224 for screenshots and more details about the feature.

Current status: Investigating the root cause of the test failures to ensure proper functionality of the restored changes.

@Saixel Saixel added NIH CAFE Issues related to and/or funded by the NIH CAFE project FY25 Sprint 18 FY25 Sprint 18 (2025-02-26 - 2025-03-12) labels Mar 6, 2025
@Saixel Saixel added this to the 6.6 milestone Mar 6, 2025
@Saixel Saixel requested a review from pdurbin March 6, 2025 13:34
@Saixel Saixel self-assigned this Mar 6, 2025
@Saixel Saixel requested a review from qqmyers March 6, 2025 13:34
@Saixel Saixel moved this to In Progress 💻 in IQSS Dataverse Project Mar 6, 2025
@github-actions

This comment has been minimized.

.where(
criteriaBuilder.equal(subqueryRoot.get("dataverse"), dataverseRoot),
criteriaBuilder.equal(subqueryRoot.get("datasetFieldType"), datasetFieldTypeJoin)
);
Copy link
Member

@qqmyers qqmyers Mar 6, 2025

Choose a reason for hiding this comment

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

I suggested changing this in the earlier PR since, at that point, displayOnCreate could be false incorrectly due to the default of setting it false in the code changes above. Is this still an issue - i.e. the default should be null and this subquery should only return 1 if displayOnCreate is not null (so that line 84 below lets you get the default value)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qqmyers You raise a good point. Currently, when no input level is configured, displayOnCreate defaults to false, which might hide fields that should be shown by default. We should consider making displayOnCreate nullable in DatasetFieldType and only setting it to false when explicitly configured in the input level. This would allow the default displayOnCreate value from the field type to be used when no input level is specified. Do you agree? Or am I missing something?

Copy link
Member

@qqmyers qqmyers Mar 6, 2025

Choose a reason for hiding this comment

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

Yes - that's what I was suggesting - I think you then have to adjust this subquery to add a check for displayOnCreate not null so that you get the default when it is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qqmyers Changes added in the commit 15fc52c

Copy link
Member

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@qqmyers qqmyers Mar 7, 2025

Choose a reason for hiding this comment

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

Sorry - Or maybe not - I think the nullable Boolean is needed on the DataverseFieldTypeInputLevel and not on the DatasetFieldType - the field type will always be true or false, but the input level might not be set it at all.

- Added @column annotation for displayOnCreate field in DatasetFieldType
- Updated JsonPrinter to include displayOnCreate in display condition
@Saixel
Copy link
Contributor Author

Saixel commented Mar 6, 2025

First fix: Resolved an issue where the displayOnCreate field was not being properly handled in the API response. The problem was in the JsonPrinter logic, which wasn't correctly processing the displayOnCreate property when generating the JSON response.

Specific Changes:

  • Modified the JsonPrinter logic to properly handle the displayOnCreate property in the JSON output
  • Verified that the field is correctly included in the API response
  • Confirmed that the testLinkInstrumentToAstro test passes successfully

Verification:

  • The testLinkInstrumentToAstro test passes successfully
  • Verified that the astroInstrument field's displayOnCreate property is correctly included in the API response

@github-actions

This comment has been minimized.

@Saixel
Copy link
Contributor Author

Saixel commented Mar 6, 2025

The test testListMetadataBlocks in DataversesIT shows different results depending on the test execution order:

Behavior:

  • When run in isolation (with a clean application state), the test passes successfully
  • When run after testLinkInstrumentToAstro, the test fails because it receives 3 metadata blocks instead of the expected 2

Root Cause:
The issue occurs because testLinkInstrumentToAstro modifies the displayOnCreate property of the astrophysics metadata block to true. This state change persists in the application and affects subsequent tests. When testListMetadataBlocks is executed, it receives the modified state where astrophysics has displayOnCreate=true, causing the test to fail.

Impact:
This reveals a test dependency issue where tests are not properly isolated from each other. While the functionality works correctly in a clean state, the test suite's reliability is compromised by these hidden dependencies. Also, I have checked and this also happens in develop without the new feature changes.

@coveralls
Copy link

Coverage Status

coverage: 22.729% (-0.01%) from 22.741%
when pulling 404eb0b on 10476-display-on-create-field-option-new
into 7a29522 on develop.

@coveralls
Copy link

coveralls commented Mar 6, 2025

Coverage Status

coverage: 22.595% (-0.02%) from 22.614%
when pulling 56cfa92 on 10476-display-on-create-field-option-new
into 8553d77 on develop.

@github-actions

This comment has been minimized.

- Clarify that required fields are always displayed regardless of displayOnCreate setting
@Saixel
Copy link
Contributor Author

Saixel commented Mar 6, 2025

It seems that the build is still failing. I've run the 4 failing tests locally and they all pass successfully:

  1. testLinkInstrumentToAstro (DatasetTypesIT)
  2. testUpdateDatasetTypeLinksWithMetadataBlocks (DatasetTypesIT)
  3. testSummaryDatasetVersionsDifferencesAPI (DatasetsIT)
  4. testListMetadataBlocks (MetadataBlocksIT)

This suggests there might be an environment difference in Jenkins causing these failures. Could you please check the Jenkins logs for any specific details about why these tests are failing? Any hints or tips on how I should proceed would be very helpful.

I have run the tests one by one by restarting the application. I did the tests in the commit 3c4e5cc.

Saixel and others added 4 commits March 6, 2025 19:23
- Change displayOnCreate to nullable Boolean in DatasetFieldType
- Update API and service methods to handle null displayOnCreate values
- Modify native API documentation to explain null displayOnCreate behavior
- Add null checks in MetadataBlockServiceBean queries
- Modified JsonPrinter to handle null values for displayOnCreate
- Updated BriefJsonPrinter to use null-safe comparison
- Update MetadataBlock to safely check displayOnCreate with null values
- Modify JsonPrinter to default displayOnCreate to false when null
- Ensure consistent null-safe handling of displayOnCreate across components
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:10476-display-on-create-field-option-new
ghcr.io/gdcc/configbaker:10476-display-on-create-field-option-new

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@Saixel Saixel requested review from pdurbin and sekmiller March 13, 2025 16:54
@Saixel Saixel moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project Mar 13, 2025
@pdurbin pdurbin marked this pull request as ready for review March 13, 2025 18:18
@pdurbin pdurbin changed the title fix: Restore metadata block changes and fix test issues Metadata fields can be set to "display on create" per collection Mar 13, 2025
@pdurbin pdurbin changed the title Metadata fields can be set to "display on create" per collection Metadata fields can be "display on create" per collection Mar 13, 2025
- ``include``: Whether the field is included (boolean)
- ``displayOnCreate`` (optional): Whether the field is displayed during dataset creation, even when not required (boolean)

.. code-block:: bash
Copy link
Contributor

Choose a reason for hiding this comment

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

by the way - the "fully expanded" example down below here has bad data - "required": true, "included": false

- ``datasetFieldTypeName``: Name of the metadata field
- ``required``: Whether the field is required (boolean)
- ``include``: Whether the field is included (boolean)
- ``displayOnCreate`` (optional): Whether the field is displayed during dataset creation, even when not required (boolean)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the code currently allows this to be optional - line 806 in Dataverses sets it to false by default. I've tried to handle this in #11330, which should be ~ up to date with this PR, but still checking to see if I've broken tests. (I also added a test updating an inputLevel with no displayOnCreate value in that PR).

Copy link
Contributor

Choose a reason for hiding this comment

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

for the doc can we just say that it default to false if omitted?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm the dummy who wrote the migration script and didn't default the column to false. Should I add another update? Are we ready for more flyway migration errors?

Copy link
Member

Choose a reason for hiding this comment

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

This would be a backward incompatibility - if you don't include displayOnCreate you will override any true on the datasetfieldtype itself. If that's OK, then yes a doc change could address it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right. didn't think of that.
\

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better if it's omitted that the value would come from the table for that datasetFieldType?

Copy link
Contributor

@sekmiller sekmiller left a comment

Choose a reason for hiding this comment

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

Saw a minor doc issue - noted below, but it existed prior to this PR.

Thanks for all of your hard work on this, Alexis

@github-project-automation github-project-automation bot moved this from Ready for Review ⏩ to Ready for QA ⏩ in IQSS Dataverse Project Mar 13, 2025
@ofahimIQSS ofahimIQSS self-assigned this Mar 13, 2025
@ofahimIQSS ofahimIQSS moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project Mar 13, 2025
@ofahimIQSS
Copy link
Contributor

ofahimIQSS commented Mar 13, 2025

adding testing evidence:

image

image

image

tests are passing:
image

@ofahimIQSS
Copy link
Contributor

Merging PR - no issues found.

@ofahimIQSS ofahimIQSS merged commit 1480dbc into develop Mar 13, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from QA ✅ to Merged 🚀 in IQSS Dataverse Project Mar 13, 2025
@ofahimIQSS ofahimIQSS deleted the 10476-display-on-create-field-option-new branch March 13, 2025 21:22
@ofahimIQSS ofahimIQSS removed their assignment Mar 13, 2025
@qqmyers qqmyers mentioned this pull request Mar 17, 2025
@scolapasta scolapasta moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY25 Sprint 18 FY25 Sprint 18 (2025-02-26 - 2025-03-12) FY25 Sprint 19 FY25 Sprint 19 (2025-03-12 - 2025-03-26) NIH CAFE Issues related to and/or funded by the NIH CAFE project Size: 3 A percentage of a sprint. 2.1 hours.

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

8 participants