Skip to content

Conversation

@kevinmarete
Copy link
Contributor

@kevinmarete kevinmarete commented Jan 29, 2026

Addresses

https://broadworkbench.atlassian.net/browse/DT-2775

Summary

This PR improves submission validation errors so users can easily understand what’s missing and where to fix it. Instead of showing internal schema paths and raw validation output, error messages now use user-facing field names and group missing required fields by asset type (e.g., Study, Dataset, Publication).

When required fields are missing, the system displays a single consolidated error message that lists all missing fields by asset type, helping users quickly navigate to the correct section of the form. Errors are cleared once all required fields are fixed and validation passes.


Have you read CONTRIBUTING.md lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@kevinmarete kevinmarete self-assigned this Jan 29, 2026
@kevinmarete kevinmarete changed the title Km dt 2775 improve submission error messaging [DT-2775] Improve Data Submission Error Messaging Jan 29, 2026
@sonarqubecloud
Copy link

@rushtong
Copy link
Contributor

I would suggest pulling all the GsonUtil changes out into a separate PR to make this more manageable since many are unrelated to the ticket. Also, there is a static GsonUtil.getInstance() method that is shorthand for all of the GsonUtil.gsonBuilderWithAdapters().create() changes.

if (registration.getAssets() != null) {
// Validate models
List<AIModel> models = registration.getModels();
for (AIModel model : models) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest moving each class' validation logic into the class itself so the logic can be accessed from anywhere the class is used rather than in this monster-class. I think that would make it easier to collect errors up into some kind of summary.

(timestamp, type, jsonSerializationContext) ->
new JsonPrimitive(timestamp.getTime()))
.create();
Gson gson = GsonUtil.gsonBuilderWithAdapters().create();
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is functionally equivalent, but test coverage here is low. Would be nice to ensure no regressions with this.

},
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["name", "url", "format", "license", "maintainer"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is one of the reasons we've tried to get away from using the schema for rule-based validation. Having a schema purely for format/type has been helpful, but logical conditions have made any work in this area extremely slow. This change is effectively a schema version change and theoretically, would require APIs to be backward compatible, or we write new versions to accommodate the new schema version.

Additionally, the UI reads this file when performing validation. Any changes here might require additional UI work to ensure these new properties don't cause regressions.

Comment on lines +334 to +336
try (var response =
resource.updateVoteRationale(
authUser, GsonUtil.gsonBuilderWithAdapters().create().toJson(update))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In this class, we have a constructed gson on line 50 that could be reused in all of the try statements.

@@ -0,0 +1,34 @@
package org.broadinstitute.consent.http.util.gson;

import static org.junit.jupiter.api.Assertions.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use star imports. I know we had a project level setting at one point, not sure if that's still the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

At a high level, what I was thinking about with this ticket was making changes in line with this documentation here:
https://github.com/networknt/json-schema-validator/blob/1.5.9/doc/cust-msg.md

The examples demonstrate how to enrich the schema with more friendly error messages that can align with the UI expectations we have.

@kevinmarete
Copy link
Contributor Author

Closing this PR, in favor of this #2792

@kevinmarete kevinmarete deleted the km_DT-2775_improve_submission_error_messaging branch January 31, 2026 00:40
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.

4 participants