Skip to content

resolve type mismatches and validation errors in streak route #545

@nivedha2025cse-gif

Description

@nivedha2025cse-gif

Is your feature request related to a problem? Please describe.

The /api/streak route was throwing several compilation errors during development due to a strict structural type mismatch with BadgeParams. Optional query parameters parsed by Zod as string | undefined were causing type assignment errors, and the custom year validation refinement was incorrectly using standard return blocks instead of the Zod context ctx.

Describe the solution you'd like

Corrected year validation inside lib/validations.ts using superRefine and native ctx.addIssue.

  • Updated app/api/streak/route.ts to build the params object safely, filtering out or explicitly casting optional parameters to satisfy BadgeParams.
  • Maintained raw values for color strings (bg, text, accent) to avoid test assertion mismatches.Corrected year validation inside lib/validations.ts using superRefine and native ctx.addIssue.
  • Updated app/api/streak/route.ts to build the params object safely, filtering out or explicitly casting optional parameters to satisfy BadgeParams.
  • Maintained raw values for color strings (bg, text, accent) to avoid test assertion mismatches.

Describe alternatives you've considered

Additionally, testing assertions failed because custom colors were altered incorrectly and the year validator error message string mismatched expected test constants.

@JhaSourav07 kindly assign it...I fixed that issue. once to assign it to me, I will cerate pull request

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions