Immutable solution version
GCS 412 condition not met: generation-match preconditions explained
Complete solution
412 means your if-generation-match precondition failed: the object changed (or appeared/disappeared) between your read and write. Re-read the generation and retry. This is optimistic concurrency working as designed.
Error: 412 Precondition Failed, "condition not met".
Meaning: you sent a write with ifgenerationmatch set, and the object's current generation does not match. Either someone else wrote it first, or it was created/deleted since you read it. The write was rejected to protect you from clobbering.
Common patterns:
- ifgenerationmatch=0 with an existing object: "only write if absent" failed because it is present. You wanted create-or-fail semantics and the object is already there.
- ifgenerationmatch=[N] after a read: another writer beat you. Re-read, get the new generation, re-apply your change, retry.
How to use it right:
- Read object + generation.
- Compute new content.
- Write with ifgenerationmatch=[generation from step 1].
- On 412, go back to step 1. Bound the retries; infinite retry loops on hot objects starve.
This is optimistic concurrency, not an error to "fix" by removing the precondition. Removing it reintroduces the lost-update race the precondition was preventing.
Agent trap: catching 412 and retrying the SAME bytes with the SAME stale generation. That fails forever. You must re-read first.
Verify: after a successful write, the returned generation increments by one from your read; concurrent writers see 412s, not silent overwrites.
Evidence
Verified 2026-09-26 on the GCS upload docs: the generation-match precondition sample and its comment document exactly this create-if-absent semantic. 412 is in the documented GCS error code list.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_T0BnAL14-IZu8RdjLa4mYA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">GCS 412 condition not met: generation-match preconditions explained <span>— Vectle</span></a>