Skip to content

Conversation

@sherinabr
Copy link

@sherinabr sherinabr commented Nov 13, 2025

What this PR does

Extract the hardcoded "error merging partial responses" string into an exported constant ErrMergingPartialResponseStr in shard_by_series_base.go.

Which issue(s) this PR fixes or relates to

N/A

Fixes #
N/A

Checklist

  • [N/A ] Tests updated.
  • [N/A ] Documentation added.
  • [N/A ] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • [N/A] about-versioning.md updated with experimental features.

Note

Introduces ErrMergingPartialResponseStr and replaces hardcoded "error merging partial responses" strings in middlewares, unifying log and response error formatting.

  • Query middleware:
    • Constant: Add exported ErrMergingPartialResponseStr in pkg/frontend/querymiddleware/shard_by_series_base.go.
    • Error handling:
      • Replace hardcoded "error merging partial responses" with the constant in shard_active_series.go and shard_active_native_histogram_metrics.go.
      • Standardize error/log output to "%s: %s" format using the constant for both logs and JSON responses.

Written by Cursor Bugbot for commit 0939782. This will update automatically on new commits. Configure here.

…nseStr

constant to avoid duplication and allow external services to reference it
for retry logic.
@CLAassistant
Copy link

CLAassistant commented Nov 13, 2025

CLA assistant check
All committers have signed the CLA.

@sherinabr sherinabr added the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Nov 13, 2025
@sherinabr sherinabr marked this pull request as ready for review November 13, 2025 10:18
@sherinabr sherinabr requested a review from a team as a code owner November 13, 2025 10:19
@sherinabr sherinabr requested review from a team, stevesg and tacole02 as code owners November 13, 2025 17:15
@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

There's a lot of unrelated changes here and I don't think the core change of inspecting error messages is a robust approach for retries.


const (
// ErrMergingPartialResponseStr is the error message used when merging partial responses from sharded queries fails.
// This is used by the recommendations service (backend-enterprise repo) to determine whether to retry requests.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should be inspecting error messages to determine if requests should be retried. The query-frontend sets reasonable HTTP status codes and the APIErrors returned set a type that can be used to determine if something is transient or not.

Copy link
Author

@sherinabr sherinabr Nov 20, 2025

Choose a reason for hiding this comment

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

Sorry for the delayed response.
This PR was created because the Active Series API sometimes returns an HTTP 200 (with no error) along with a partial result. Since no error is returned, the recommendations engine proceeds with the incomplete data and computes the series counts, which leads to incorrect values being shown in the UI.
I’ve started a Slack thread with more context. If Active Series API could return an error in this case, we wouldn't need any of these changes.

@sherinabr sherinabr force-pushed the sherin/use-error-string-for-error-merging-partial-responses branch 2 times, most recently from c2044ec to ca6a63a Compare November 13, 2025 18:25
@sherinabr sherinabr removed request for a team, stevesg and tacole02 November 13, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-not-needed PRs that don't need a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants