Skip to content

Correct format lookup logic. Always map primary type to itself in Con… - #1862

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

Correct format lookup logic. Always map primary type to itself in Con…#1862
MikeNeilson wants to merge 11 commits into
developfrom
bugfix/1861-recents-default-format

Conversation

@MikeNeilson

Copy link
Copy Markdown
Contributor

…tentTypeAliasMap.

Summary

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

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

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.

I would remove this from this PR

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.

yeah, that one keeps sneaking in.

@krowvin krowvin Aug 5, 2026

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.

This looks like it's trying to accommodate the change for
https://github.com/USACE/cwms-data-api/pull/1862/changes#r3721590710

Should we just revert this and undo that other change. Just thinking it might be out of scope for the header fix

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.

I might, see below.

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.

.jsonConfig(
JsonConfig.jsonConfig()
.numberReturnType(JsonPathConfig.NumberReturnType.DOUBLE));
.numberReturnType(JsonPathConfig.NumberReturnType.DOUBLE))

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.

If we set all JSON numbers to double won't this break many of the existing integration tests?

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.

It shouldn't as this was always supposed to be set, and we were setting it manually in the time series tests.

I might change it back though, at least for the numbers, the real change is the adding of the content type processing, only just realized we needed to actually assign the new config to the global, so it wasn't properly active before.

import cwms.cda.formatters.xml.XMLv2;

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

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.

Suggested change
@FormattableWith(contentType = Formats.JSONV2, formatter = XMLv2.class, aliases = {Formats.JSON})
@FormattableWith(contentType = Formats.JSONV2, formatter = JsonV2.class, aliases = {Formats.JSON})

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.

Intentional, the processing actually bypasses the formatter lookup... though I should add a comment about it.

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.

have changed it to a "DUMMY" outputformatter so the intentional is more clear.

@MikeNeilson
MikeNeilson force-pushed the bugfix/1861-recents-default-format branch from 49fc7e9 to bd3cb26 Compare August 5, 2026 17:28
@MikeNeilson
MikeNeilson force-pushed the bugfix/1861-recents-default-format branch from e1b6693 to d69e54b Compare August 5, 2026 19:19
@MikeNeilson
MikeNeilson requested a review from krowvin August 5, 2026 22:23
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