Skip to content

Conversation

@wied03
Copy link
Contributor

@wied03 wied03 commented Dec 22, 2025

If we use [invalid], applications that define a default message will show a rather empty, generic message, rather than the Jackson message, unless a specific message is defined.

This was not the desired behavior. The desired behavior was to allow an application to define a more specific message if it wanted to, otherwise fall back to the default Jackson message.

@wied03 wied03 requested review from bhalsey and spwitt December 22, 2025 15:20
Copy link
Contributor

@bhalsey bhalsey left a comment

Choose a reason for hiding this comment

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

We'll need to introduce a generic invalidEnum message in fusionauth-app before we use this, right?

@wied03
Copy link
Contributor Author

wied03 commented Dec 22, 2025

We'll need to introduce a generic invalidEnum message in fusionauth-app before we use this, right?

Yes. But if we don't, for any given code path, there should be no regression or change in behavior.

Copy link
Contributor

@spwitt spwitt left a comment

Choose a reason for hiding this comment

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

So the impact of the PMVC change on FusionAuth is that API requests using the enum for the field type will now return the [invalidEnum]field.name error. These currently return a JSON parsing exception that has the detail a dev might need, but it's not very friendly.

But if we don't, for any given code path, there should be no regression or change in behavior.

If we ship the PMVC update and miss defining the [invalidEnum] error code on some context, I think that's an exception for a missing message key. That would be a change in behavior, right?

String message = null;
if (matchesEnumNotValidValue.matches() && matchesEnumNotValidValue.groupCount() == 2) {
code = "[invalid]%s".formatted(field);
code = "[invalidEnum]%s".formatted(field);
Copy link
Contributor

Choose a reason for hiding this comment

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

invalidEnum feels a little off to me, but I can't put my finger on why. Too Java focused? Too much detail?

Is there something more generic like invalidOption or invalidSelection that would work?

If no one else has an issue, we can keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Push includes this change. Arguably not a patch release. In practice, not sure how much matters.

@wied03
Copy link
Contributor Author

wied03 commented Dec 22, 2025

So the impact of the PMVC change on FusionAuth is that API requests using the enum for the field type will now return the [invalidEnum]field.name error. These currently return a JSON parsing exception that has the detail a dev might need, but it's not very friendly.

But if we don't, for any given code path, there should be no regression or change in behavior.

If we ship the PMVC update and miss defining the [invalidEnum] error code on some context, I think that's an exception for a missing message key. That would be a change in behavior, right?

It was supposed to fallback to Jackson, but reading the code again, this is not tested, and not likely what would happen. I will go ensure this is tested and works.

Base automatically changed from bhalsey/eng-3701-fix-multiple-headers to main December 22, 2025 18:43
@wied03
Copy link
Contributor Author

wied03 commented Dec 22, 2025

So the impact of the PMVC change on FusionAuth is that API requests using the enum for the field type will now return the [invalidEnum]field.name error. These currently return a JSON parsing exception that has the detail a dev might need, but it's not very friendly.

But if we don't, for any given code path, there should be no regression or change in behavior.

If we ship the PMVC update and miss defining the [invalidEnum] error code on some context, I think that's an exception for a missing message key. That would be a change in behavior, right?

It was supposed to fallback to Jackson, but reading the code again, this is not tested, and not likely what would happen. I will go ensure this is tested and works.

Tested this (and this type of mock was not doing a lot of us here, so removed that).

@wied03 wied03 merged commit 1cfaefd into main Dec 22, 2025
1 check passed
@wied03 wied03 deleted the wied03/enum_message branch December 22, 2025 19:58
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