Skip to content

Fix Discord validation errors by making discordProfile fields optional #424

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

Closed
wants to merge 1 commit into from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 11, 2025

This PR fixes a Zod validation error that occurs when users authenticate with Discord but have incomplete profile data. The error manifests as:

ZodError: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": ["discordProfile", "nick"],
    "message": "Required"
  },
  {
    "code": "invalid_type",
    "expected": "object", 
    "received": "undefined",
    "path": ["discordProfile", "user"],
    "message": "Required"
  }
]

Root Cause

The validation schema in @epic-web/workshop-utils requires discordProfile.nick and discordProfile.user to be present when a discordProfile object exists. However, the Epic API sometimes returns a discordProfile object with undefined values for these fields when Discord integration is incomplete or partially configured.

Solution

Applied a patch to make the nick and user fields optional within the discordProfile schema:

  • nick: z.string().nullable()nick: z.string().nullable().optional()
  • user: z.object({...})user: z.object({...}).optional()

This follows the same pattern used to resolve the similar issue #393, where the entire discordProfile was made optional and nullable.

Implementation

  • Added patch-package as a dev dependency in the epicshop package
  • Created a patch file that modifies the validation schema in @epic-web/workshop-utils
  • Added a postinstall script to automatically apply patches on fresh installs
  • Tested the fix with both problematic and normal Discord profile data

The workshop now starts successfully regardless of Discord profile completion status, while maintaining all existing functionality for users with complete Discord profiles.

Fixes #423.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.cloudflare.com
    • Triggering command: node --import=file:///home/REDACTED/work/react-fundamentals/react-fundamentals/epicshop/node_modules/@epic-web/workshop-app/instrument.js ./start.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Author

Copilot AI commented Aug 11, 2025

@kentcdodds 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@kentcdodds kentcdodds closed this Aug 11, 2025
@Copilot Copilot AI changed the title [WIP] Discord validation errors after npm run start Fix Discord validation errors by making discordProfile fields optional Aug 11, 2025
@Copilot Copilot AI requested a review from kentcdodds August 11, 2025 13:25
Copilot finished work on behalf of kentcdodds August 11, 2025 13:25
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.

2 participants