Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Parse JSON metadata better and stop crash from API V1 #18756

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

alishaz-polymath
Copy link
Member

What does this PR do?

Currently, our V1 API fails because of JSON schema validation we have with zod for V1 because it doesn't have the ability to parse nested array, objects or null values.

We add parsing for these and that sorts out the bug.
This bug also causes the 3rd party apps using V1 to fail as well, such as Raycast.

Mandatory Tasks (DO NOT REMOVE)

  • N/A - I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • N/A - I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Before:

  • Add giphy app to one of your event types
  • Enable it
  • Disable it
  • Run API V1 for event-types and see the error:
{"message":"invalid_type in 'metadata': Expected string, received object; invalid_type in 'metadata': Expected number, received object; invalid_type in 'metadata': Expected boolean, received object; invalid_type in 'metadata': Expected array, received object; invalid_type in 'metadata,apps': Expected string, received object; invalid_type in 'metadata,apps': Expected number, received object; invalid_type in 'metadata,apps': Expected boolean, received object; invalid_type in 'metadata,apps': Expected array, received object; invalid_type in 'metadata,apps,giphy': Expected string, received object; invalid_type in 'metadata,apps,giphy': Expected number, received object; invalid_type in 'metadata,apps,giphy': Expected boolean, received object; invalid_type in 'metadata,apps,giphy': Expected array, received object; invalid_type in 'metadata,apps,giphy,price': Expected string, received null; invalid_type in 'metadata,apps,giphy,price': Expected number, received null; invalid_type in 'metadata,apps,giphy,price': Expected boolean, received null; invalid_type in 'metadata,apps,giphy,price': Expected array, received null; invalid_type in 'metadata,apps,giphy,price': Expected object, received null; invalid_type in 'metadata,apps,giphy,TRACKING_ID': Expected string, received null; invalid_type in 'metadata,apps,giphy,TRACKING_ID': Expected number, received null; invalid_type in 'metadata,apps,giphy,TRACKING_ID': Expected boolean, received null; invalid_type in 'metadata,apps,giphy,TRACKING_ID': Expected array, received null; invalid_type in 'metadata,apps,giphy,TRACKING_ID': Expected object, received null"}

After:

  • Run API V1 for event-types again, and the error is gone, parsing works!

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jan 20, 2025
@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth 🐛 bug Something isn't working labels Jan 20, 2025
Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 7:16am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 7:16am

Copy link

graphite-app bot commented Jan 20, 2025

Graphite Automations

"Add ready-for-e2e label" took an action on this PR • (01/20/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

E2E results are ready!

@PeerRich PeerRich merged commit 02ef6dc into main Jan 20, 2025
60 of 61 checks passed
@PeerRich PeerRich deleted the fix/raycast-event-type-crash branch January 20, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth 🐛 bug Something isn't working core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants