Skip to content

fix: Correct Schemas#45

Open
RyanBrim12 wants to merge 2 commits into
boorad:mainfrom
RyanBrim12:main
Open

fix: Correct Schemas#45
RyanBrim12 wants to merge 2 commits into
boorad:mainfrom
RyanBrim12:main

Conversation

@RyanBrim12

@RyanBrim12 RyanBrim12 commented Jul 6, 2026

Copy link
Copy Markdown

This PR fixes schema validation issues caused by GHIN API responses that are more flexible than the current models expected.

What changed

  • search.ts
    • Updated the Golfers schema so first_name can be absent/empty instead of failing validation.
    • This prevents false validation errors when GHIN returns a golfer record without a first name.
    • This can occur for some searches such as ghinClient.golfers.search({last_name: 'Martin', country: 'USA'})
  • post-response.ts
    • Added Temporary to the allowed score status values in the score post-response schema.
  • score.ts
    • Extended the raw score status mapping to support Temporary and map it to the internal TEMPORARY status.
      Why
      GHIN sometimes returns:
  • golfer records with no first_name
  • score responses with status: Temporary

These were previously rejected by the strict Zod schemas, causing unnecessary validation failures. The update aligns the client model with real GHIN behavior and removes those unneeded errors.

Summary by CodeRabbit

  • New Features
    • Score records now support an additional status option, helping newer score states display and process correctly.
  • Bug Fixes
    • Search results now handle missing or blank golfer first names more gracefully.
    • Score status values are now recognized more consistently across the app.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates two Zod schemas: schemaGolfer.first_name changes from a required string to an optional emptyStringToNull field, and score status schemas (rawScoreStatuses, schemaRawScoreStatus, scoreStatusesMap, and post-response status enum) are extended to support a new Temporary value mapped to TEMPORARY.

Changes

Score Status Handling

Layer / File(s) Summary
Extend score status enum and mapping
src/client/ghin/models/scores/score.ts, src/client/ghin/models/scores/post-response.ts
rawScoreStatuses, schemaRawScoreStatus, and scoreStatusesMap now include Temporary, mapped to TEMPORARY; the post-response status enum also accepts Temporary.

Golfer Schema

Layer / File(s) Summary
Optional first_name field
src/client/ghin/models/golfers/search.ts
schemaGolfer.first_name changes from required string to an optional emptyStringToNull value, converting empty strings to null and allowing omission.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • boorad/ghin#31: Both PRs modify the schemaScorePostResponseInner schema in post-response.ts.

Poem

Hop hop, a status new appears,
"Temporary" joins its peers,
First names now can hide away,
Empty strings turn null today,
A rabbit's schema, tuned just right! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the changes, but it is too generic to describe the specific schema fixes made in the PR. Use a more specific title, such as mentioning the golfer first_name handling and Temporary score status updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/client/ghin/models/scores/post-response.ts (1)

8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse shared status enum instead of duplicating literals.

This enum duplicates rawScoreStatuses/schemaRawScoreStatus in score.ts. This very PR required updating both places identically to add Temporary — export and reuse the shared enum to prevent future drift.

♻️ Proposed fix
-    status: z.enum(['Validated', 'UnderReview', 'Temporary']),
+    status: schemaRawScoreStatus,

(export schemaRawScoreStatus from score.ts and import it here)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/client/ghin/models/scores/post-response.ts` at line 8, The status enum in
the post response schema is duplicated and should reuse the shared score status
definition instead of hardcoding literals. Export the existing shared enum from
score.ts (schemaRawScoreStatus / rawScoreStatuses) and import it into
post-response.ts, then wire the status field to that shared symbol so both
schemas stay in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/client/ghin/models/scores/post-response.ts`:
- Line 8: The status enum in the post response schema is duplicated and should
reuse the shared score status definition instead of hardcoding literals. Export
the existing shared enum from score.ts (schemaRawScoreStatus / rawScoreStatuses)
and import it into post-response.ts, then wire the status field to that shared
symbol so both schemas stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3bcff33-81b2-4039-bbad-588c6f7b193e

📥 Commits

Reviewing files that changed from the base of the PR and between 04fdb45 and c888037.

📒 Files selected for processing (3)
  • src/client/ghin/models/golfers/search.ts
  • src/client/ghin/models/scores/post-response.ts
  • src/client/ghin/models/scores/score.ts

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.

1 participant