Skip to content

fix(cognito): register VerificationCode for reflection so HybridStora… - #1646

Merged
hectorvent merged 1 commit into
floci-io:mainfrom
dzwicker:fix/cognito-password-reset-reflection
Jul 3, 2026
Merged

fix(cognito): register VerificationCode for reflection so HybridStora…#1646
hectorvent merged 1 commit into
floci-io:mainfrom
dzwicker:fix/cognito-password-reset-reflection

Conversation

@dzwicker

Copy link
Copy Markdown
Contributor

Summary

In a native image, Jackson could not serialize VerificationCode because it lacked reflection metadata, so HybridStorage can wrote cognito-verification-codes.json.

Closes #1586

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Incorrect behavior: Cognito state failed to persist in the native image (No serializer found for class ... VerificationCode). This fix restores persistence.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits

…ge can persist state

In a native image, Jackson could not serialize VerificationCode because it lacked reflection metadata, so HybridStorage can wrote cognito-verification-codes.json.

Refs floci-io#1586
@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds the @RegisterForReflection annotation to VerificationCode so that GraalVM native-image builds expose the class to Jackson's reflective serializer, restoring persistence of cognito-verification-codes.json via HybridStorage.

  • Adds @RegisterForReflection and its import to VerificationCode.java — the minimal change needed to fix the reported "No serializer found" error in native-image mode.
  • The nested Purpose enum does not require a separate annotation; GraalVM/Quarkus handles plain enum constants as reachable image objects without explicit reflection metadata.

Confidence Score: 5/5

Safe to merge; the change is a single annotation addition that restores native-image serialization for VerificationCode with no behavioural impact on JVM builds.

The diff is a one-annotation, one-import change that matches the pattern used consistently for all other serializable model classes in this codebase. The fix directly addresses the reported serialization failure, and existing tests pass. No logic is altered.

No files require special attention.

Important Files Changed

Filename Overview
src/main/java/io/github/hectorvent/floci/services/cognito/verification/VerificationCode.java Adds @RegisterForReflection to allow Jackson to serialize/deserialize this class in a GraalVM native image; change is minimal, correct, and consistent with how other model classes in this codebase are handled.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[HybridStorage write] --> B[Jackson ObjectMapper serializes VerificationCode]
    B --> C{Native Image?}
    C -- Before fix --> D["No reflection metadata\n→ SerializationException\n'No serializer found'"]
    C -- After fix --> E["@RegisterForReflection\n→ metadata available at image build time"]
    E --> F[Serialization succeeds]
    F --> G[cognito-verification-codes.json written]
    D --> H[File never written — state lost]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[HybridStorage write] --> B[Jackson ObjectMapper serializes VerificationCode]
    B --> C{Native Image?}
    C -- Before fix --> D["No reflection metadata\n→ SerializationException\n'No serializer found'"]
    C -- After fix --> E["@RegisterForReflection\n→ metadata available at image build time"]
    E --> F[Serialization succeeds]
    F --> G[cognito-verification-codes.json written]
    D --> H[File never written — state lost]
Loading

Reviews (3): Last reviewed commit: "fix(cognito): register VerificationCode ..." | Re-trigger Greptile

@dzwicker
dzwicker marked this pull request as draft June 30, 2026 10:52
@dzwicker
dzwicker marked this pull request as ready for review June 30, 2026 11:57
@hectorvent hectorvent added bug Something isn't working cognito Amazon Cognito labels Jul 1, 2026

@hectorvent hectorvent 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 @dzwicker

@hectorvent
hectorvent merged commit ed81f2b into floci-io:main Jul 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cognito Amazon Cognito

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Cognito ForgotPassword fails to persist VerificationCode state (InvalidDefinitionException)

2 participants