> ## Documentation Index
> Fetch the complete documentation index at: https://gtmsdk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix: rejected domain PATCH re-reads before classifying a concurrent fill

> The matching validation_type rejection early-returned domain_invalid without re-reading, so a concurrent writer that filled the domains slot between the GET and the rejected PATCH was classified unresolved; the matching branch now re-reads and reports domains_already_set.

## Bug fixes

**Rejected domains PATCH now re-reads before classifying a concurrent fill (issue #917)**

`set_company_domain_if_empty`'s two error branches after a rejected domains
PATCH classified the same race outcome differently. The non-matching branch
(uniqueness conflict, 5xx, schema mismatch) re-reads the record and, if a
concurrent writer filled the `domains` slot in the pre-PATCH-GET → PATCH
window, returns `domains_already_set` → orchestrator `noop_had_domain`. The
matching `validation_type` rejection introduced in #898 (to fix #888)
early-returned `domain_invalid` without that re-read, so the identical race
outcome — a record that ends with a domain — was classified `unresolved`
("still needs a domain"). A single-run counter off-by-one that self-corrects
on the next run, but the two branches disagreed on the identical race
outcome, which misleads anyone tracing an `unresolved` for a record that
visibly has a domain.

The matching branch now re-reads before classifying, and a single
conditional return chooses `domains_already_set` (concurrent writer won) or
`domain_invalid` (still empty), so both error branches agree on the race
outcome. The re-read failure path re-raises the original PATCH error
(`raise exc from e`), mirroring the non-matching branch's error-handling
contract — no swallowing of server rejections. The narrow recheck preserves
the #888/#898 fix (empty → `unresolved`) and restores the race case (filled →
`noop_had_domain`); the matching branch is collapsed to a single return to
stay under the lint return-count.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.