api-platform-errors

A guide for handling API errors in API Platform 4.3, a framework for building web APIs with Symfony. It uses RFC 7807, a standard JSON format for explaining failed requests.

In plain words
What is it for?
Use it when mapping domain errors to responses, documenting expected failures in OpenAPI, hiding sensitive server details, or customizing problem responses.
Why use it?
It helps keep error responses consistent, safe in production, and clearly documented for API users. It also explains how application exceptions become HTTP status codes such as 404, 422, or 500.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/gerard-labs/superpowers-api-platform/api-platform-errors
Any agent
npx skills add gerard-labs/superpowers-api-platform --skill api-platform-errors
Clone the repo
git clone --depth 1 https://github.com/gerard-labs/superpowers-api-platform

Made for: Claude Code, Codex.

Per session 314 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 871 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00314 $0.00871
Opus 5 $0.00157 $0.00436
Sonnet 5 $0.00063 $0.00174
Haiku 4.5 $0.00031 $0.00087

Measured yesterday against content hash 3ef5ea4ae145, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-platform-errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/api-platform-errors/SKILL.md · 47 lines

How it starts

The opening of the file, as written. The whole thing — 47 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Platform 4.3 — Errors (RFC 7807, ErrorResource, custom Error Provider)

Use when

  • Designing a new domain exception and how it surfaces in the API.
  • Mapping exception → status code globally or per operation.
  • Hiding 500 stack traces in production while keeping meaningful 4xx errors.
  • Adding errors: [DomainException::class] so OpenAPI documents the failure case.
  • Customizing the error provider to enrich Problem Detail payloads (type, title, instance).

Default workflow

  1. Confirm rfc_7807_compliant_errors: true is set (default in 4.x — Problem Detail format).
  2. For each domain exception, decide: exceptionToStatus mapping, #[ErrorResource] (documented + customizable), or rely on the default.
  3. Add errors: [...] on relevant operations so OpenAPI documents the failure cases.
  4. Implement a custom Error Provider only when you need to enrich the Problem payload (setDetail, type, instance).
  5. Verify: 422 / 404 / 409 / 410 / 500 all round-trip with the correct Content-Type: application/problem+json.

Guardrails

  • No stack traces / file paths in production. A 500 always gets a generic detail.
  • No business details in 401 / 403. Enumeration risk — generic "Access denied".
  • Stable type URIs. Clients pattern-match on them — version them (/errors/v1/stock-unavailable).
  • ValidationException namespace: in 4.x it lives at ApiPlatform\Validator\Exception\ValidationException. The legacy ApiPlatform\Symfony\… path is removed.

Progressive disclosure

  • SKILL.md covers posture and rules.
  • reference.md carries the full config, exceptionToStatus levels, #[ErrorResource] template, custom Error Provider with Error::createFromException, status resolution order, validation error provider, prod-safe pattern, type versioning.

Output contract

  • Domain exceptions either mapped via exceptionToStatus or modeled as #[ErrorResource] with ProblemExceptionInterface.
  • Operations declaring errors: [...] for documented failure modes.
  • Tests asserting application/problem+json Content-Type and the exact type / title / status fields.
  • Production environment configured to hide stack traces.

Read the full file on GitHub · 47 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 47 lines · 0 tokens per session scan A 3ef5ea4ae145

Subscribe to this mod's changes

api-platform-errors is a skill published in the GitHub repository gerard-labs/superpowers-api-platform (2 stars, last pushed 3mo ago), licensed MIT. It adds 314 tokens to every session and 871 once invoked, about $0.0016 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

nextjs-pages-router

Set up tRPC in Next.js Pages Router with createNextApiHandler, createTRPCNext, withTRPC HOC, SSR via ssr option and ssrPrepass, SSG via createServerSideHelpers with getStaticProps, and server-side helpers for getServerSideProps prefetching.

trpc/trpc · 67 tokens

react-query-setup

Set up @trpc/tanstack-react-query with createTRPCContext(), TRPCProvider, useTRPC() hook, queryOptions/mutationOptions factories, query invalidation via queryClient.invalidateQueries with queryFilter, and type inference with inferInput/inferOutput.

trpc/trpc · 60 tokens

non-json-content-types

Handle FormData, file uploads, Blob, Uint8Array, and ReadableStream inputs in tRPC mutations. Use octetInputParser from @trpc/server/http for binary data. Route non-JSON requests with splitLink and isNonJsonSerializable() from @trpc/client. FormData and binary inputs only work with mutations (POST).

trpc/trpc · 75 tokens

openapi-glossary

Use consistent OpenAPI terminology and definitions when writing documentation, educational material, and tooling guidance.

scalar/scalar · 24 tokens

scalar-docs

Skill for writing and updating scalar.config.json — Scalar Docs configuration reference for users and LLMs.

scalar/scalar · 24 tokens

create-tutorial

Scaffold a new Membrane API Gateway tutorial in the api-gateway repo — the numbered self-teaching YAML under distribution/tutorials/ /, its support files and README links, and the matching auto-discovered integration test. Use whenever the user asks to create, add, write, or scaffold a tutorial (or a tutorial step)…

membrane/api-gateway · 97 tokens