Troubleshooting
Find answers to common issues, error messages, and configuration problems when using Prisma Guard.
Common Issues & Solutions
1. Cannot find module '../generated/zod/user' or similar import error
- Cause: Your TypeScript compiler or application is trying to import Zod schemas that have not been generated yet, or were removed during a project clean step.
- Solution: Run the generation command to compile the schemas to your local directory:
npx prisma-guard
2. VS Code snippets not working in .prisma files
- Cause: VS Code has not yet loaded the updated snippet files into its active window memory.
- Solution: Reload your editor window to flush the snippet cache:
- Action: Open the Command Palette (
Ctrl+Shift+Pon Windows/Linux,Cmd+Shift+Pon macOS) and run:
Developer: Reload Window
- Action: Open the Command Palette (
3. My custom decorators aren't being applied
- Cause: Either your decorator name has a typo, or the comment decorator is configured using the wrong annotation.
- Solution: Verify that:
- The decorator key exists in the
decoratorsobject ofprisma-guard.config.js. - The schema field is annotated using the matching decorator name in the Prisma file:
/// @zod.use(decoratorName)
- The decorator key exists in the
4. My @default values disappeared from Zod schemas!
If you are using /// @zod.z. overrides and your Prisma @default() is not showing up:
- Why: By default, explicit absolute overrides assume you want full control over the type definition, including default value bounds, which strips the default database mappings from the generated schemas.
- Fix: Set
defaultsOnOverride: truein your configuration to automatically append.default()to your overrides:// prisma-guard.config.jsexport default defineConfig({defaultsOnOverride: true,});
5. Prisma is yelling about missing required fields!
- The Scenario: You generated your Prisma Guard field mappings, later added a new required column to your Prisma schema, but forgot to regenerate. Prisma Guard's runtime stripper did exactly what it was designed to do—it didn't recognize the new field, stripped it from your input, and then Prisma yelled at you because a required database field was missing!
- The Fix: Always remember to run
npx prisma-guardafter modifying your schema to update your mappings, or usenpx prisma-guard --watchduring development to avoid this completely!
Active Debugging
[!TIP] Pro Tip: If you're ever unsure why data isn't saving or why Prisma is complaining, temporarily set
debug: truein yourprisma-guard.config.js:// prisma-guard.config.jsexport default defineConfig({debug: true,});You'll get helpful console logs at runtime like:
[prisma-guard] Stripping extra field "newColumn" from model "User"!