Skip to content

Correct format lookup logic. And a few other things - #1862

Open
MikeNeilson wants to merge 13 commits into
developfrom
bugfix/1861-recents-default-format
Open

Correct format lookup logic. And a few other things#1862
MikeNeilson wants to merge 13 commits into
developfrom
bugfix/1861-recents-default-format

Conversation

@MikeNeilson

@MikeNeilson MikeNeilson commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Process the provided header in such a way as to not accidentally attempt to use an incorrect content type.

primary fix, always map the primary content type to itself.
Remove the logic in parseHeader that allow creating an unmapped ContentType object.
Then add appropriate annotations to deal with the fallout of doing that.

Related Issue

Closes #1861

Validation

Additional test for Formats, existing tests.

Checklist

  • AI tools used

@krowvin krowvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Appears to be failing tests from this PR and the package lock slipped in again

Comment thread cda-gui/package-lock.json
Comment thread cwms-data-api/src/test/java/cwms/cda/api/BasinControllerIT.java
Comment on lines -415 to -422
} else {
//If the DTO parameter is null, alias map is empty. Compare against well-known types
//Only use the ContentType classes initialized in contentTypeList rather than
//the client headers itself
ContentType type = new ContentType(ct);
if (contentTypeList.contains(type)) {
contentTypes.add(type);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the CI tests this looks like it's causing the existing JSON/XML requests to return 406

i.e.

833 tests completed, 83 failed, 20 skipped

via
https://github.com/USACE/cwms-data-api/actions/runs/30954615142/job/92144620012

BasinControllerIT.test_get_create_delete expected HTTP 200 but received 406

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.

Yep... that's the problem. The removal of this code is correct, otherwise an invalid type "mapping" gets in below instead of properly failing, so now I'm dealing with the affects of that.

Comment thread cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java Outdated
Comment thread cwms-data-api/src/main/java/cwms/cda/data/dto/rating/Ratings.java Outdated
@MikeNeilson
MikeNeilson force-pushed the bugfix/1861-recents-default-format branch 2 times, most recently from e1b6693 to d69e54b Compare August 5, 2026 19:19
@MikeNeilson
MikeNeilson requested a review from krowvin August 5, 2026 22:23

@krowvin krowvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing those other concerns.

Just had one comment about the Locaiton.java class.

and

This PR is starting to get large because it also looks like you bumped the DB image, updated location delete error handling, and are tweaking the RSS rate limit test. (You may want to change the PR title if the scope was intended to be larger?)

This might turn into one of those endless soups!

@FormattableWith(contentType = Formats.XMLV2, formatter = XMLv2.class, aliases = {Formats.XML})
@FormattableWith(contentType = Formats.JSONV2, formatter = JsonV2.class, aliases = {Formats.DEFAULT, Formats.JSON})
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class)
@FormattableWith(contentType = Formats.GEOJSON, formatter = JsonV2.class)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this going to apply to every endpoint of Location.class (not just the getAll)?

If it makes a GET /locations/{id} accept geo+json and serializes JSON v2, it will label it GeoJSON no?

Might need a get all specific marker instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because later the normal formatter gets called here

String serializedLocation = Formats.format(contentType, location);

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.

Hmm, yeah, that one should probably be the DUMMY formatter.

But to be clear the format mapping is per dto/content-type an end point may further constrain, or redirect if it needs to.

@MikeNeilson

Copy link
Copy Markdown
Contributor Author

Thanks for fixing those other concerns.

Just had one comment about the Locaiton.java class.

and

This PR is starting to get large because it also looks like you bumped the DB image, updated location delete error handling, and are tweaking the RSS rate limit test. (You may want to change the PR title if the scope was intended to be larger?)

This might turn into one of those endless soups!

Thankfully, this is the end. I could've waited on the RSS limit but it was just bugging the crap out of me. The db image was a simple one, finally got release so needed an update.

That said, thanks for pushing back on scope keep, it generally is a bad idea.

@MikeNeilson MikeNeilson changed the title Correct format lookup logic. Always map primary type to itself in Con… Correct format lookup logic. And a few other things Aug 6, 2026
@MikeNeilson
MikeNeilson force-pushed the bugfix/1861-recents-default-format branch from ecfc930 to caf7286 Compare August 6, 2026 18:25
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.

[Bug]: Timeseries Recent call forces conflicting formats on call

2 participants