Skip to content

fix(navigation/tablet-errors): fix showing errors for replicated tables#1342

Open
ainthero wants to merge 1 commit intoytsaurus:mainfrom
ainthero:fix/replicated-tablet-errors
Open

fix(navigation/tablet-errors): fix showing errors for replicated tables#1342
ainthero wants to merge 1 commit intoytsaurus:mainfrom
ainthero:fix/replicated-tablet-errors

Conversation

@ainthero
Copy link

@ainthero ainthero commented Oct 23, 2025

Summary by Sourcery

Fix showing errors for replicated tables by updating the API batch request to retrieve the replicas map, summing per-replica error counts, and combining them with the table-level error count.

Bug Fixes:

  • Fix tablet errors count for replicated tables by summing individual replica error_count fields and including table-level count.

Enhancements:

  • Update API batch request to fetch full replicas map and handle missing or invalid replicas data.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 23, 2025

Reviewer's Guide

Updates the tablet error count flow by revising the batch API request to retrieve the full replicas map, applying type-safe aggregation of per-replica error_count with fallback handling, and combining it with the table-level error counter.

Sequence diagram for updated tablet error count aggregation

sequenceDiagram
participant Dispatch
participant Toaster
participant ytApiV3Id
participant UpdateTabletErrorsCount
Dispatch->>Toaster: wrapApiPromiseByToaster(ytApiV3Id.executeBatch(...))
Toaster->>ytApiV3Id: executeBatch with requests:\n- get replicas map\n- get tablet_error_count
ytApiV3Id-->>Toaster: [replicas, tabletErrorCount]
Toaster->>Dispatch: then()
Dispatch->>UpdateTabletErrorsCount: updateTabletErrrosCount(replicasErrors + tableErrors, path)
Loading

Class diagram for updated error count aggregation logic

classDiagram
class LoadTabletErrorOptions {
    path: string
    saveCancelTokenSource: any
}
class TabletErrorsThunkAction
class ytApiV3Id {
    +executeBatch(parameters)
}
class updateTabletErrrosCount {
    +updateTabletErrrosCount(count, path)
}
LoadTabletErrorOptions <.. TabletErrorsThunkAction
TabletErrorsThunkAction --> ytApiV3Id: uses
TabletErrorsThunkAction --> updateTabletErrrosCount: dispatches
Loading

File-Level Changes

Change Details Files
Revise batch API request structure for error counts
  • Change executeBatch generic from number to any
  • Move requests array under a parameters object
  • Add descriptive comments to each request
packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts
Replace direct error count fetch with full replicas map
  • Fetch full @replicas object instead of @replicas/@error_count
  • Still retrieve @tablet_error_count for table-level errors
packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts
Implement safe aggregation of per-replica errors
  • Destructure API outputs into replicas and tabletErrorCount
  • Compute replicasErrors by mapping and reducing error_count with type checks
  • Wrap aggregation in try/catch to default to zero on failure
  • Combine replicasErrors with tableErrors before dispatch
packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Replace the use of any for the API response with a properly typed interface to improve type safety and catch parsing issues at compile time.
  • Consider extracting the replica error-count summing logic into a standalone helper function to simplify the thunk and make it easier to unit test.
  • Rather than swallowing all errors in the catch block, log or surface parsing failures so debugging unexpected replica formats is easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Replace the use of `any` for the API response with a properly typed interface to improve type safety and catch parsing issues at compile time.
- Consider extracting the replica error-count summing logic into a standalone helper function to simplify the thunk and make it easier to unit test.
- Rather than swallowing all errors in the catch block, log or surface parsing failures so debugging unexpected replica formats is easier.

## Individual Comments

### Comment 1
<location> `packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts:147-149` </location>
<code_context>
-            dispatch(updateTabletErrrosCount(count, path));
+        ).then(([{output: replicas}, {output: tabletErrorCount}]) => {
+            let replicasErrors = 0;
+            if (replicas && typeof replicas === 'object') {
+                try {
+                    replicasErrors = Object.values(replicas as Record<string, any>)
+                        .map((r: any) => (typeof r?.error_count === 'number' ? r.error_count : 0))
+                        .reduce((a: number, b: number) => a + b, 0);
+                } catch {
+                    replicasErrors = 0;
+                }
</code_context>

<issue_to_address>
**suggestion:** Catching all errors without logging may hide underlying issues.

Consider logging the error in the catch block or adding a comment to clarify why silent failure is acceptable, to support future debugging.

```suggestion
                } catch (error) {
                    console.error('Failed to calculate replicasErrors:', error);
                    replicasErrors = 0;
                }
```
</issue_to_address>

### Comment 2
<location> `packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts:151-152` </location>
<code_context>
+                    replicasErrors = 0;
+                }
+            }
+            const tableErrors = typeof tabletErrorCount === 'number' ? tabletErrorCount : 0;
+            dispatch(updateTabletErrrosCount(replicasErrors + tableErrors, path));
         });
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Tablet error count fallback to 0 may mask unexpected API responses.

Consider logging a warning or error when tabletErrorCount is not a number to help identify unexpected API responses early.

```suggestion
            let tableErrors: number;
            if (typeof tabletErrorCount === 'number') {
                tableErrors = tabletErrorCount;
            } else {
                console.warn(
                    `[tablet-errors-background] Unexpected tabletErrorCount value:`,
                    tabletErrorCount,
                    'for path:',
                    path
                );
                tableErrors = 0;
            }
            dispatch(updateTabletErrrosCount(replicasErrors + tableErrors, path));
```
</issue_to_address>

### Comment 3
<location> `packages/ui/src/ui/store/actions/navigation/tabs/tablet-errors/tablet-errors-background.ts:152` </location>
<code_context>
+                }
+            }
+            const tableErrors = typeof tabletErrorCount === 'number' ? tabletErrorCount : 0;
+            dispatch(updateTabletErrrosCount(replicasErrors + tableErrors, path));
         });
     };
</code_context>

<issue_to_address>
**nitpick (typo):** Typo in 'updateTabletErrrosCount' function name.

Please rename the function to 'updateTabletErrorsCount'.

Suggested implementation:

```typescript
            dispatch(updateTabletErrorsCount(replicasErrors + tableErrors, path));

```

If the function `updateTabletErrrosCount` is defined or imported elsewhere in this file, you should also rename its definition or import to `updateTabletErrorsCount`. Additionally, update any other usage of the old name in this file or related files to maintain consistency.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +147 to +149
} catch {
replicasErrors = 0;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Catching all errors without logging may hide underlying issues.

Consider logging the error in the catch block or adding a comment to clarify why silent failure is acceptable, to support future debugging.

Suggested change
} catch {
replicasErrors = 0;
}
} catch (error) {
console.error('Failed to calculate replicasErrors:', error);
replicasErrors = 0;
}

}
}
const tableErrors = typeof tabletErrorCount === 'number' ? tabletErrorCount : 0;
dispatch(updateTabletErrrosCount(replicasErrors + tableErrors, path));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Typo in 'updateTabletErrrosCount' function name.

Please rename the function to 'updateTabletErrorsCount'.

Suggested implementation:

            dispatch(updateTabletErrorsCount(replicasErrors + tableErrors, path));

If the function updateTabletErrrosCount is defined or imported elsewhere in this file, you should also rename its definition or import to updateTabletErrorsCount. Additionally, update any other usage of the old name in this file or related files to maintain consistency.

@ma-efremoff
Copy link
Collaborator

Can you please provide more details? Why do we need the fix?

@ainthero
Copy link
Author

Can you please provide more details? Why do we need the fix?

In the current version, the "Errors" tab doesn’t appear for replicated tables when there are errors on replicas or tablets, unlike dyntables. You have to go to the "Tablets" tab, find the tablet with an error, open it, and only then you can see the error details. This fix resolves that issue.

@ma-efremoff
Copy link
Collaborator

Thank you for the details, I will discuss the fix with API team.

@ma-efremoff ma-efremoff removed the request for review from KostyaAvtushko January 12, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants