Skip to content

Disable client-side validation of responses #490

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

Merged
merged 2 commits into from
May 16, 2025

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented May 16, 2025

Problem

Sometimes unexpected values in API responses can cause unnecessary errors due to validation logic being applied. Fields labeled in the openapi as enum fields will error when unexpected values appear in the response. In general, we want the client to just display what the API returns without applying validation.

Solution

Adjust the code generation to disable validation logic when instantiating model objects from API response.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Plan

I created a mock server script to do some manual testing of different responses with odd values in them and saw this works without erroring. For example, these responses no longer raise:

  • New index status
  • Index dimension > 20k
  • Index name too long

@jhamon jhamon force-pushed the jhamon/no-clientside-validation branch from 9d1209f to 674a390 Compare May 16, 2025 15:38
@jhamon jhamon marked this pull request as ready for review May 16, 2025 15:38
if (name,) in self.validations and self._enforce_validations:
# Disabling validation on response makes the SDK
# less fragile if unexpected values are returned. In general,
# we want the SDK to display whatever is returned by the API.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is where the logic change actually comes into force.

@jhamon jhamon merged commit 24296eb into release-candidate/2025-04 May 16, 2025
71 of 72 checks passed
@jhamon jhamon deleted the jhamon/no-clientside-validation branch May 16, 2025 16:14
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