The analysis of the security patch d0cd103a92cc1915636733fb1d1730c2c7f74851 reveals that the vulnerability was located in the PostgreSQL datastore implementation of SpiceDB. The root cause was a silent failure in the pgReadWriteTXN.WriteRelationships function. The function performed bulk database writes but did not check for errors after the operation completed using rows.Err(). When a user submitted a WriteRelationships request with a number of updates exceeding PostgreSQL's internal limit of 65,535 parameters, the database would generate an error, but the application would ignore it. This resulted in the relationships not being written to the database, while the API call misleadingly reported success. Consequently, subsequent permission checks could return incorrect results.
The patch rectifies this by adding an explicit error check (if rows.Err() != nil) after the database query. It also introduces a new error handling function, handleWriteError, which specifically identifies the PostgreSQL parameter limit error and translates it into a clear, application-specific WriteOverLimitError. This ensures that such failures are no longer silent and are properly reported to the user.