Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle 201 response from write endpoint #1044

Merged
merged 2 commits into from
Aug 14, 2024
Merged

fix: handle 201 response from write endpoint #1044

merged 2 commits into from
Aug 14, 2024

Conversation

jacobmarble
Copy link
Member

@jacobmarble jacobmarble commented Aug 13, 2024

InfluxDB v3 returns 201 for partial write errors.

Helps internal issue https://github.com/influxdata/idpe/issues/18710

Proposed Changes

Briefly describe your proposed changes:

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • yarn test completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

InfluxDB v3 returns 201 for partial write errors.
Copy link

@abshierjoel abshierjoel left a comment

Choose a reason for hiding this comment

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

Looks great! I was following along on the EAR 🙏 Thanks for the quick fix.

// older implementations of transport do not report status code
if (responseStatusCode == 204 || responseStatusCode == undefined) {
if (

Choose a reason for hiding this comment

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

Is it worth handling all 2XX status codes here, in case this changes in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! But! Read this and tell me what you think:
#263

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion is to modify the behavior of the clients as follows: v2 clients will accept 204 and 201 HTTP status codes, and v3 clients will accept any 2xx status codes. I've updated our backlog item accordingly and included a link to #263 - https://github.com/orgs/influxdata/projects/108/views/1?pane=issue&itemId=73988042.

Choose a reason for hiding this comment

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

We'll also want to make the response body of a 201 partial write accessible to the caller, whether through a log or some other way I don't have a preference. 👍

Copy link

@savage-engineer savage-engineer Aug 14, 2024

Choose a reason for hiding this comment

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

@bednar I would raise a PR to log a warning on 201 myself, but I can't see where the response body is bound/accessible in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Grepping the repo for "partial", it documents the 400 service behavior, but doesn't handle it. Since the SaaS products will soon return 400 instead of 201, I thought it isn't worth the effort to do anything more than this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@savage-engineer, the WriteApiImpl does not operate with the response HTTP body. To access the response, you should add a next callback

Choose a reason for hiding this comment

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

Ah I see, if I understand correctly the user of the client API library is able to do that?

If that's the case then I'm happy! 👌

Copy link
Contributor

Choose a reason for hiding this comment

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

No, if there is an error from InfluxDB, the client parses the "error state" from the response body and propagates it as an Error.

Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

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

Thanks for your PR 👍

LGTM 🚀

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7bd9fb9) to head (b980cce).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1044   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           35        35           
  Lines         1449      1450    +1     
  Branches       344       345    +1     
=========================================
+ Hits          1449      1450    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bednar bednar merged commit fff3615 into master Aug 14, 2024
5 checks passed
@bednar bednar deleted the jgm-write-201 branch August 14, 2024 09:45
@bednar bednar added this to the 1.35.0 milestone Aug 14, 2024
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.

6 participants