Skip to content

Conversation

astandrik
Copy link
Collaborator

@astandrik astandrik commented Sep 17, 2025

Closes #2894

Stand

Greptile Summary

Updated On: 2025-09-17 17:56:56 UTC

This PR introduces proper error handling for streaming queries in the YDB Embedded UI by adding error chunk detection functionality. The change addresses issue #2894 related to shard overload handling by adding an isErrorChunk utility function that identifies error responses in streaming data and modifying the streaming API to handle these error chunks appropriately.

The implementation adds a type guard function isErrorChunk in src/store/reducers/query/utils.ts that detects whether a streaming chunk contains error information by checking for the presence of 'error' or 'issues' properties. This function is then utilized in src/services/api/streaming.ts to identify error chunks early in the parsing pipeline and throw them as exceptions before attempting to process them as regular streaming chunks.

The solution fits well within the existing streaming architecture by adding a safety layer that prevents error responses from being misprocessed as regular streaming data. This is particularly important because error responses have a different structure than expected streaming chunks (which contain meta.event properties), and attempting to process them as such would cause runtime errors.

Important Files Changed

Changed Files
Filename Score Overview
src/store/reducers/query/utils.ts 4/5 Added isErrorChunk utility function to detect error responses in streaming chunks
src/services/api/streaming.ts 4/5 Integrated error chunk detection and improved error handling in streaming API

Confidence score: 4/5

  • This PR addresses a specific error handling issue with a focused solution that improves robustness
  • Score reflects that the type guard could be more strict and error throwing could provide clearer messaging
  • Pay close attention to the error handling logic in both files to ensure proper error propagation

Context used:

Style Guide - description of repository for agents (link)

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
378 373 0 3 2
Test Changes Summary ⏭️2

⏭️ Skipped Tests (2)

  1. Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view (tenant/diagnostics/tabs/queries.test.ts)
  2. Copy result button copies to clipboard (tenant/queryEditor/queryEditor.test.ts)

Bundle Size: ✅

Current: 85.49 MB | Main: 85.49 MB
Diff: +1.07 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes handling of shard overload errors in the streaming API by adding proper error chunk detection and handling. The fix prevents error responses from being processed as regular streaming chunks, which could cause issues when the server returns error responses due to shard overload conditions.

  • Adds a new isErrorChunk utility function to detect error responses in streaming data
  • Updates streaming API to check for and throw error chunks before processing as regular streaming chunks
  • Refactors chunk processing logic to improve error handling flow

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/store/reducers/query/utils.ts Adds isErrorChunk type guard function and imports ErrorResponse type
src/services/api/streaming.ts Updates streaming parser to detect and handle error chunks, refactors chunk processing logic

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Raubzeug
Raubzeug previously approved these changes Sep 18, 2025
@astandrik
Copy link
Collaborator Author

@Raubzeug added explicit request cancellation
stand redeployed

@astandrik astandrik added this pull request to the merge queue Sep 18, 2025
Merged via the queue into main with commit bfb4b36 Sep 18, 2025
7 checks passed
@astandrik astandrik deleted the astandrik.2894 branch September 18, 2025 10:19
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.

fix: shard overload handle
2 participants