@@ -34,14 +34,14 @@ var ErrNumWriteResultExceedsTotalRecords = errors.New(
3434// and
3535// len(Results) ≤ totalNumRecords.
3636//
37- // - fatalErrors represent top-level (batch-level) errors that may coexist
38- // with item-level successes. For example, partial API failures or warnings
39- // that affected only some records .
37+ // - unmatchedErrors represent provider responses that could not be associated
38+ // with specific payload items — for example, schema validation issues or
39+ // general API errors returned alongside per-record results .
4040//
4141// Constructors may return an error to signal invalid or inconsistent usage
4242// rather than to represent runtime provider failures.
4343func NewBatchWriteResult (
44- results []WriteResult , successCounter , totalNumRecords int , fatalErrors []any ,
44+ results []WriteResult , successCounter , totalNumRecords int , unmatchedErrors []any ,
4545) (* BatchWriteResult , error ) {
4646 if len (results ) > totalNumRecords {
4747 return nil , errors .Join (ErrInvalidImplementation , ErrNumWriteResultExceedsTotalRecords )
@@ -55,7 +55,7 @@ func NewBatchWriteResult(
5555
5656 return & BatchWriteResult {
5757 Status : newBatchStatus (successCounter , failureCounter , totalNumRecords ),
58- Errors : fatalErrors ,
58+ Errors : unmatchedErrors ,
5959 Results : results ,
6060 SuccessCount : successCounter ,
6161 FailureCount : failureCounter ,
@@ -67,18 +67,17 @@ func NewBatchWriteResult(
6767// BatchStatus as failure. The constructor still validates that the number of
6868// WriteResult entries does not exceed totalNumRecords.
6969//
70- // fatalErrors may include provider-level or transport-level issues explaining
71- // the batch failure.
70+ // unmatchedErrors may include provider-level issues explaining the failure that cannot be tied to specific records.
7271func NewBatchWriteResultFailed (
73- results []WriteResult , totalNumRecords int , fatalErrors []any ,
72+ results []WriteResult , totalNumRecords int , unmatchedErrors []any ,
7473) (* BatchWriteResult , error ) {
7574 if len (results ) > totalNumRecords {
7675 return nil , errors .Join (ErrInvalidImplementation , ErrNumWriteResultExceedsTotalRecords )
7776 }
7877
7978 return & BatchWriteResult {
8079 Status : newBatchStatus (0 , totalNumRecords , totalNumRecords ),
81- Errors : fatalErrors ,
80+ Errors : unmatchedErrors ,
8281 Results : results ,
8382 SuccessCount : 0 ,
8483 FailureCount : totalNumRecords ,
@@ -146,14 +145,14 @@ var ErrBatchUnprocessedRecord = errors.New("record was not processed due to othe
146145// payloadItems - list of items that are part of payload to create/update each record.
147146// responseMatcher - list of items that are part of payload to create/update each record.
148147// responseToResult - a transformer that converts a matched item pair (payload P, response R) into a WriteResult.
149- // fatalErrors – top-level errors not tied to individual records,
148+ // unmatchedErrors – top-level errors not tied to individual records,
150149//
151150// such as validation failures detected before response matching.
152151func ParseBatchWrite [P , R any ](
153152 payloadItems []P ,
154153 responseMatcher BatchWriteResponseMatcher [P , R ],
155154 responseToResult BatchWriteResponseTransformer [P , R ],
156- fatalErrors []any ,
155+ unmatchedErrors []any ,
157156) (* BatchWriteResult , error ) {
158157 var (
159158 totalNumRecords = len (payloadItems )
@@ -170,7 +169,7 @@ func ParseBatchWrite[P, R any](
170169
171170 result , err := responseToResult (record , response )
172171 if err != nil {
173- fatalErrors = append (fatalErrors , err )
172+ unmatchedErrors = append (unmatchedErrors , err )
174173
175174 // Record cannot be added into the list of results ([]WriteResult).
176175 continue
@@ -185,7 +184,7 @@ func ParseBatchWrite[P, R any](
185184 }
186185 }
187186
188- return NewBatchWriteResult (results , successCounter , totalNumRecords , fatalErrors )
187+ return NewBatchWriteResult (results , successCounter , totalNumRecords , unmatchedErrors )
189188}
190189
191190func countSuccesses (results []WriteResult ) int {
0 commit comments