cajias/claude-skills/fastify-url-special-characters
Claude Code and agent skill by cajias/claude-skills
- community
Checking that the SKILL.md file is still in the repository.
Fix test failures when validating route parameters with special characters in Fastify. Use when: (1) Tests expect 400 but get 404 for invalid route parameters, (2) Special characters like # @ are being stripped from URLs before handler runs, (3) Route parameter validation tests fail unexpectedly. Covers Fastify URL parsing behavior and how to test parameter validation correctly.
Install
npx vskill@latest install cajias/claude-skills/fastify-url-special-charactersSKILL.md
The same SKILL.md was published earlier as cajias/claude-skills/fastify-url-special-characters.
Fastify URL Special Characters in Route Parameters
Problem
When testing route parameter validation in Fastify, tests may fail because certain special characters are handled at the routing level before your handler runs. You expect 400 Bad Request from your validation but get 404 Not Found because Fastify never matched your route.
Context / Trigger Conditions
- Test expects
400status code but receives404 - Testing route parameter validation with special characters
- Using Fastify with dynamic route parameters like
/gateways/:gatewayId/mcp - Characters like
#,?, or URL-encoded values in test URLs
Example test that fails unexpectedly:
Root Cause
Fastify (and most HTTP frameworks) parse URLs according to RFC 3986:
- `#` (hash/fragment): Everything after
#is treated as a fragment and stripped
/gateways/invalid@gateway#id/mcp→/gateways/invalid@gateway(route doesn't match)
- `?` (query string): Everything after
?is parsed as query parameters
/gateways/test?id/mcp→ route is/gateways/testwith queryid/mcp
- URL encoding: Some characters are decoded before routing
%20(space) is passed through to handler%2F(/) may cause routing issues
Solution
Step 1: Identify Which Characters Fastify Passes Through
Characters that reach your handler (can be validated):
- Letters, numbers, hyphens, underscores:
a-z,A-Z,0-9,-,_ - Dots:
.(passed through) - Spaces (URL-encoded as
%20): decoded and passed through @symbol: passed through
Characters that DON'T reach your handler:
#- Treated as fragment start, URL truncated?- Treated as query string start/- Path separator (even when encoded)
Step 2: Update Tests to Use Passable Invalid Characters
Step 3: Test Each Validation Rule Separately
Verification
Test that your validation pattern correctly rejects the characters you care about:
Example
Real-world fix from MCP Proxy service:
Notes
- This behavior is consistent across most HTTP frameworks, not just Fastify
- The RFC 3986 URL spec defines this parsing behavior
- If you need to accept special characters in route parameters, consider:
- Base64 encoding the parameter value
- Using query parameters instead of path parameters
- URL-encoding and decoding manually
References
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/fastify-url-special-characters/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cajias/claude-skills/fastify-url-special-characters)