Skip to content

Conversation

@webintellectual
Copy link

@webintellectual webintellectual commented Oct 22, 2025

Overview

client.create_customer() method is throwing exception even after successfully creating the customer. The problem is in response status handling. The code is considering 200 as success status code while POST endpoint gives 201 as success status code.

Fixes #(issue)
client.create_customer() in python api client

Notes for reviewer

Summary by CodeRabbit

  • Bug Fixes
    • Fixed customer creation API response handling to properly recognize successful creation with the correct HTTP status code. This ensures the API client accurately processes customer creation requests.

client.create_customer() method is throwing exception even after successfully creating the customer.
The problem is in response status handling. The code is considering 200 as success status code while POST endpoint gives 201 as success status code.

Signed-off-by: Akshay <[email protected]>
@webintellectual webintellectual requested a review from a team as a code owner October 22, 2025 07:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

📝 Walkthrough

Walkthrough

The create_customer function in the API client was updated to expect HTTP 201 Created as the success response instead of HTTP 200 OK. The success condition check and documentation were adjusted accordingly to reflect this change.

Changes

Cohort / File(s) Summary
API Client Status Code Update
api/client/python/src/openmeter/_operations/_operations.py
Updated create_customer success-path check from status code 200 to 201, and aligned documented example to reflect HTTP 201 response.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Update response status code from 200 to 201 for create_customer method in python api client" directly and accurately describes the main change in the changeset. It clearly specifies the action being taken (updating response status code), the specific change (from 200 to 201), the method affected (create_customer), and the context (python api client). The title is specific, concise, and free from vague terms or noise, allowing a teammate reviewing the commit history to immediately understand the primary purpose of this change. The change summary confirms this is exactly what the PR accomplishes—adjusting the success-path check from status_code [200] to [201] to fix an issue where the method incorrectly treated HTTP 201 responses as errors.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 867155d and 4ba18c2.

📒 Files selected for processing (1)
  • api/client/python/src/openmeter/_operations/_operations.py (3 hunks)
🔇 Additional comments (2)
api/client/python/src/openmeter/_operations/_operations.py (2)

1499-1546: Doc example updated to 201 — LGTM

Example reflects the correct 201 Created status.


1697-1702: Now I'll inspect the specific lines mentioned in the review comment to verify the documentation inconsistency:

Based on my verification:

✓ 201 success check aligns with HTTP standards for resource creation

The 201 Created status code indicates that a request was successful and resulted in the creation of a new resource, making the runtime check at lines 1697-1702 correct for create_customer.

However, since this is an AutoRest-generated file, the proper fix is to update the OpenAPI/Swagger specification and regenerate the client. AutoRest reads OpenAPI input files to produce a code model consumed by language-specific code generators, ensuring specs and code stay in sync.

No direct callers to create_customer were found in the Python codebase—the search showed 200 checks only in other unrelated operations, which are correct for those endpoints. Backward compatibility risk is low if the server now consistently returns 201.

Verify that:

  • The OpenAPI spec was updated to reflect 201 as the success response for create_customer
  • Documentation at line 1433 is updated or regenerated
  • The AutoRest regeneration was properly executed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant