{"record":{"id":"a13b815d1e23c2fc","repo":"multica-ai/multica","slug":"count-attribution-mismatches-w","errorCode":null,"errorMessage":"count attribution mismatches: %w","messagePattern":"count attribution mismatches: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/attributionbackfill/backfill.go","lineNumber":179,"sourceCode":"\tif log == nil {\n\t\tlog = slog.Default()\n\t}\n\tbatchSize := opts.BatchSize\n\tif batchSize <= 0 {\n\t\tbatchSize = DefaultBatchSize\n\t}\n\ttable := opts.Table\n\tif table == \"\" {\n\t\ttable = \"agent_task_queue\"\n\t}\n\n\tvar res Result\n\n\t// Surface any genuinely mis-attributed rows (both users set but\n\t// different) up front. The invariant still forces accountable to follow\n\t// originator below, but the operator/audit trail should show the count.\n\tif err := pool.QueryRow(ctx, fmt.Sprintf(countMismatchSQL, table)).Scan(&res.MismatchNormalized); err != nil {\n\t\treturn res, fmt.Errorf(\"count attribution mismatches: %w\", err)\n\t}\n\tif res.MismatchNormalized > 0 {\n\t\tlog.Warn(\"attribution backfill: normalizing rows where accountable_user_id disagreed with a non-NULL originator_user_id; originator is authoritative but these are worth auditing\",\n\t\t\t\"mismatch_rows\", res.MismatchNormalized)\n\t}\n\n\tupdateSQL := fmt.Sprintf(backfillBatchSQL, table, table)\n\tfor {\n\t\ttag, err := pool.Exec(ctx, updateSQL, batchSize)\n\t\tif err != nil {\n\t\t\treturn res, fmt.Errorf(\"backfill accountable_user_id batch: %w\", err)\n\t\t}\n\t\tn := tag.RowsAffected()\n\t\tif n == 0 {\n\t\t\tbreak\n\t\t}\n\t\tres.RowsBackfilled += n\n\t\tres.Batches++","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/attributionbackfill/backfill.go#L161-L197","documentation":"Error \"count attribution mismatches: %w\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/internal/attributionbackfill/backfill.go:179 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Investigate the attribution count mismatches; inspect the wrapped error and re-run the backfill."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}