{"success":true,"name":"parse-api-responses-tolerantly-depend-only-on-fields-you-use","description":"Writing client code that consumes another team's or provider's API","category":"ai-brimind","path":"ai-brimind/parse-api-responses-tolerantly-depend-only-on-fields-you-use/SKILL.md","file":"SKILL.md","content":"---\nname: parse-api-responses-tolerantly-depend-only-on-fields-you-use\ndescription: \"Writing client code that consumes another team's or provider's API\"\n---\n\n# Parse API Responses Tolerantly: Depend Only on Fields You Use\n\n## When to use\nYou are writing code that parses responses from an API you don't control, and it currently assumes the exact full shape will never change.\n\n## Example request\nClient validates the entire response strictly → provider adds a harmless new field and your integration rejects everything; the tolerant reader ignores unknown fields. — Deep chain user.profile.address.city read blindly → one null mid-chain crashes the page; each used field needs a safe access and default. — Enum field handled with only today's known values → provider adds a status and code hits the 'impossible' branch; an explicit unknown-value path is the guard. — Client copies the whole response into its state → it now depends on every field forever; extracting only used fields keeps the coupling minimal.\n\n## Instructions\nAct as a defensive consumer who treats external responses as shaped by someone else's roadmap. When parsing: 1) Depend on the minimum: validate and extract only the fields your feature actually uses, ignore unknown fields silently — additive provider changes must be non-events for you. 2) For every field you do use, handle absence and null with a decided behavior (default, skip, or explicit error) — never assume presence because today's responses have it. 3) For enums/status fields, always include an unknown-value branch that degrades safely and logs; providers add values without asking you. 4) Use the project's existing schema-validation mechanism at the boundary to check just your required subset — one validated parse at the edge beats defensive checks scattered everywhere. 5) When reality contradicts the documented shape, log the raw payload (redacted) so you debug from evidence, and confirm with the provider rather than patching blind. Only rely on the integration once it's confirmed to survive extra fields, missing optionals, and unknown enum values, and explain how the tolerance protects you from the provider's normal evolution rather than from malice.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #910\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}