Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BI-2355] - Non-informative error message: regression #423

Merged
merged 5 commits into from
Nov 1, 2024

Conversation

HMS17
Copy link
Contributor

@HMS17 HMS17 commented Oct 31, 2024

Description

(New branch due to soiled changelist in previous attempt)

Story: BI-2355 - Non-informative error message: regression

This error was due to tablesaw processing brackets weirdly, resulting in the column name stored in data not matching the column name stored in dynamic column names. This was fixed in two parts:

  1. Removing brackets from ontology term names on upload

  2. Preventing ontology terms with brackets in the name from being created by extending the functionality created in BI-2328

Note that this means for the error message re ontology terms not found, periods and brackets will be removed from the invalid ontology term names

Dependencies

bi-web: bug/BI-2355.2

Testing

Test that on upload of an experiment file with invalid ontology term columns headings that contain brackets and/or periods that the unknown error message no longer shows and instead the invalid ontology term message shows

Test that upload of experiment file with valid ontology terms proceeds as expected

Test that the appropriate error is thrown when an ontology term contains ".", "[" and/or "]" and that that error is not thrown when the ontology term does not contain those characters for:

  • Ontology Term Creation in UI
  • Ontology Term Edit
  • Ontology Term File Upload

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <please include a link to TAF run>

@HMS17 HMS17 changed the base branch from develop to release/1.0 October 31, 2024 19:30
@HMS17 HMS17 marked this pull request as ready for review October 31, 2024 20:09
@HMS17 HMS17 requested review from a team, dmeidlin, mlm483 and davedrp and removed request for a team and dmeidlin October 31, 2024 20:10
@HMS17 HMS17 requested review from dmeidlin and removed request for davedrp November 1, 2024 15:25
Copy link
Contributor

@mlm483 mlm483 left a comment

Choose a reason for hiding this comment

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

Tested, working.

I'm approving, but I'd recommend simplifying using the code in my comments. I tested the functionality before and after applying my change, it works either way.

Comment on lines 174 to 189
// replace certain special characters with "" in column names to deal with json flattening issue in tablesaw
// this includes ".", "[", "["
List<String> columnNames = df.columnNames();
List<String> namesToReplace = new ArrayList<>();
for (String name : columnNames) {
if (name.contains(".")) {
if (name.contains(".") || name.contains("[") || name.contains("]")) {
namesToReplace.add(name);
}
}

List<Column<?>> columns = df.columns(namesToReplace.stream().toArray(String[]::new));
for (int i=0; i<columns.size(); i++) {
Column<?> column = columns.get(i);
column.setName(namesToReplace.get(i).replace(".",""));
//if more characters, could use replaceall and regex, but this works presently
column.setName(namesToReplace.get(i).replace(".","").replace("[","").replace("]",""));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be missing something, but it seems to me that lines 174-189 could be replaced with the following with the same behavior and efficiency.

// Replace certain special characters with "" in column names to deal with json flattening issue in tablesaw,
// this includes ".", "[", "]".
df.columns().forEach(
        (c) -> c.setName(c.name().replace(".","").replace("[","").replace("]",""))
);

You could check with Nick about why the code was initially structured that way, but I think this way is more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, it looks a lot more elegant that way!

public ValidationError getPeriodObsVarNameMsg() {
return new ValidationError("observationVariableName", "Period in name is invalid", HttpStatus.BAD_REQUEST);
public ValidationError getInvalidCharObsVarNameMsg() {
return new ValidationError("observationVariableName", "Periods and brackets in name is invalid", HttpStatus.BAD_REQUEST);
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 often wrong on matters of grammar, but I think "...in name are invalid" sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@HMS17 HMS17 merged commit 0fed12c into release/1.0 Nov 1, 2024
1 check passed
@HMS17 HMS17 deleted the bug/BI-2355.2 branch November 1, 2024 21:32
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