Skip to content

Commit 24296eb

Browse files
authored
Disable client-side validation of responses (#490)
## 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 - [x] 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
1 parent 80d9c95 commit 24296eb

File tree

93 files changed

+458
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+458
-2
lines changed

pinecone/core/openapi/db_control/model/backup_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
152152
"""
153153

154154
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
155+
_enforce_validations = kwargs.pop("_enforce_validations", False)
155156
_check_type = kwargs.pop("_check_type", True)
156157
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
157158
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -170,6 +171,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
170171

171172
self._data_store = {}
172173
self._enforce_allowed_values = _enforce_allowed_values
174+
self._enforce_validations = _enforce_validations
173175
self._check_type = _check_type
174176
self._spec_property_naming = _spec_property_naming
175177
self._path_to_item = _path_to_item
@@ -191,6 +193,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
191193
required_properties = set(
192194
[
193195
"_enforce_allowed_values",
196+
"_enforce_validations",
194197
"_data_store",
195198
"_check_type",
196199
"_spec_property_naming",
@@ -240,6 +243,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
240243
"""
241244

242245
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
246+
_enforce_validations = kwargs.pop("_enforce_validations", True)
243247
_check_type = kwargs.pop("_check_type", True)
244248
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
245249
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -256,6 +260,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
256260

257261
self._data_store = {}
258262
self._enforce_allowed_values = _enforce_allowed_values
263+
self._enforce_validations = _enforce_validations
259264
self._check_type = _check_type
260265
self._spec_property_naming = _spec_property_naming
261266
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/backup_model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def _from_openapi_data(
205205
"""
206206

207207
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
208+
_enforce_validations = kwargs.pop("_enforce_validations", False)
208209
_check_type = kwargs.pop("_check_type", True)
209210
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
210211
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -223,6 +224,7 @@ def _from_openapi_data(
223224

224225
self._data_store = {}
225226
self._enforce_allowed_values = _enforce_allowed_values
227+
self._enforce_validations = _enforce_validations
226228
self._check_type = _check_type
227229
self._spec_property_naming = _spec_property_naming
228230
self._path_to_item = _path_to_item
@@ -250,6 +252,7 @@ def _from_openapi_data(
250252
required_properties = set(
251253
[
252254
"_enforce_allowed_values",
255+
"_enforce_validations",
253256
"_data_store",
254257
"_check_type",
255258
"_spec_property_naming",
@@ -316,6 +319,7 @@ def __init__(
316319
"""
317320

318321
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
322+
_enforce_validations = kwargs.pop("_enforce_validations", True)
319323
_check_type = kwargs.pop("_check_type", True)
320324
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
321325
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -332,6 +336,7 @@ def __init__(
332336

333337
self._data_store = {}
334338
self._enforce_allowed_values = _enforce_allowed_values
339+
self._enforce_validations = _enforce_validations
335340
self._check_type = _check_type
336341
self._spec_property_naming = _spec_property_naming
337342
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/byoc_spec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
141141
"""
142142

143143
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
144+
_enforce_validations = kwargs.pop("_enforce_validations", False)
144145
_check_type = kwargs.pop("_check_type", True)
145146
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
146147
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -159,6 +160,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
159160

160161
self._data_store = {}
161162
self._enforce_allowed_values = _enforce_allowed_values
163+
self._enforce_validations = _enforce_validations
162164
self._check_type = _check_type
163165
self._spec_property_naming = _spec_property_naming
164166
self._path_to_item = _path_to_item
@@ -181,6 +183,7 @@ def _from_openapi_data(cls: Type[T], environment, *args, **kwargs) -> T: # noqa
181183
required_properties = set(
182184
[
183185
"_enforce_allowed_values",
186+
"_enforce_validations",
184187
"_data_store",
185188
"_check_type",
186189
"_spec_property_naming",
@@ -231,6 +234,7 @@ def __init__(self, environment, *args, **kwargs) -> None: # noqa: E501
231234
"""
232235

233236
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
237+
_enforce_validations = kwargs.pop("_enforce_validations", True)
234238
_check_type = kwargs.pop("_check_type", True)
235239
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
236240
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -247,6 +251,7 @@ def __init__(self, environment, *args, **kwargs) -> None: # noqa: E501
247251

248252
self._data_store = {}
249253
self._enforce_allowed_values = _enforce_allowed_values
254+
self._enforce_validations = _enforce_validations
250255
self._check_type = _check_type
251256
self._spec_property_naming = _spec_property_naming
252257
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/collection_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
147147
"""
148148

149149
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
150+
_enforce_validations = kwargs.pop("_enforce_validations", False)
150151
_check_type = kwargs.pop("_check_type", True)
151152
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
152153
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -165,6 +166,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
165166

166167
self._data_store = {}
167168
self._enforce_allowed_values = _enforce_allowed_values
169+
self._enforce_validations = _enforce_validations
168170
self._check_type = _check_type
169171
self._spec_property_naming = _spec_property_naming
170172
self._path_to_item = _path_to_item
@@ -186,6 +188,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
186188
required_properties = set(
187189
[
188190
"_enforce_allowed_values",
191+
"_enforce_validations",
189192
"_data_store",
190193
"_check_type",
191194
"_spec_property_naming",
@@ -234,6 +237,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
234237
"""
235238

236239
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
240+
_enforce_validations = kwargs.pop("_enforce_validations", True)
237241
_check_type = kwargs.pop("_check_type", True)
238242
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
239243
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -250,6 +254,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
250254

251255
self._data_store = {}
252256
self._enforce_allowed_values = _enforce_allowed_values
257+
self._enforce_validations = _enforce_validations
253258
self._check_type = _check_type
254259
self._spec_property_naming = _spec_property_naming
255260
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/collection_model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
164164
"""
165165

166166
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
167+
_enforce_validations = kwargs.pop("_enforce_validations", False)
167168
_check_type = kwargs.pop("_check_type", True)
168169
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
169170
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -182,6 +183,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
182183

183184
self._data_store = {}
184185
self._enforce_allowed_values = _enforce_allowed_values
186+
self._enforce_validations = _enforce_validations
185187
self._check_type = _check_type
186188
self._spec_property_naming = _spec_property_naming
187189
self._path_to_item = _path_to_item
@@ -206,6 +208,7 @@ def _from_openapi_data(cls: Type[T], name, status, environment, *args, **kwargs)
206208
required_properties = set(
207209
[
208210
"_enforce_allowed_values",
211+
"_enforce_validations",
209212
"_data_store",
210213
"_check_type",
211214
"_spec_property_naming",
@@ -261,6 +264,7 @@ def __init__(self, name, status, environment, *args, **kwargs) -> None: # noqa:
261264
"""
262265

263266
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
267+
_enforce_validations = kwargs.pop("_enforce_validations", True)
264268
_check_type = kwargs.pop("_check_type", True)
265269
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
266270
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -277,6 +281,7 @@ def __init__(self, name, status, environment, *args, **kwargs) -> None: # noqa:
277281

278282
self._data_store = {}
279283
self._enforce_allowed_values = _enforce_allowed_values
284+
self._enforce_validations = _enforce_validations
280285
self._check_type = _check_type
281286
self._spec_property_naming = _spec_property_naming
282287
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
166166
"""
167167

168168
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
169+
_enforce_validations = kwargs.pop("_enforce_validations", False)
169170
_check_type = kwargs.pop("_check_type", True)
170171
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
171172
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -184,6 +185,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
184185

185186
self._data_store = {}
186187
self._enforce_allowed_values = _enforce_allowed_values
188+
self._enforce_validations = _enforce_validations
187189
self._check_type = _check_type
188190
self._spec_property_naming = _spec_property_naming
189191
self._path_to_item = _path_to_item
@@ -205,6 +207,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
205207
required_properties = set(
206208
[
207209
"_enforce_allowed_values",
210+
"_enforce_validations",
208211
"_data_store",
209212
"_check_type",
210213
"_spec_property_naming",
@@ -256,6 +259,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
256259
"""
257260

258261
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
262+
_enforce_validations = kwargs.pop("_enforce_validations", True)
259263
_check_type = kwargs.pop("_check_type", True)
260264
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
261265
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -272,6 +276,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
272276

273277
self._data_store = {}
274278
self._enforce_allowed_values = _enforce_allowed_values
279+
self._enforce_validations = _enforce_validations
275280
self._check_type = _check_type
276281
self._spec_property_naming = _spec_property_naming
277282
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_embed.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
148148
"""
149149

150150
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
151+
_enforce_validations = kwargs.pop("_enforce_validations", False)
151152
_check_type = kwargs.pop("_check_type", True)
152153
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
153154
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -166,6 +167,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
166167

167168
self._data_store = {}
168169
self._enforce_allowed_values = _enforce_allowed_values
170+
self._enforce_validations = _enforce_validations
169171
self._check_type = _check_type
170172
self._spec_property_naming = _spec_property_naming
171173
self._path_to_item = _path_to_item
@@ -187,6 +189,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
187189
required_properties = set(
188190
[
189191
"_enforce_allowed_values",
192+
"_enforce_validations",
190193
"_data_store",
191194
"_check_type",
192195
"_spec_property_naming",
@@ -238,6 +241,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
238241
"""
239242

240243
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
244+
_enforce_validations = kwargs.pop("_enforce_validations", True)
241245
_check_type = kwargs.pop("_check_type", True)
242246
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
243247
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -254,6 +258,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
254258

255259
self._data_store = {}
256260
self._enforce_allowed_values = _enforce_allowed_values
261+
self._enforce_validations = _enforce_validations
257262
self._check_type = _check_type
258263
self._spec_property_naming = _spec_property_naming
259264
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_spec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
151151
"""
152152

153153
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
154+
_enforce_validations = kwargs.pop("_enforce_validations", False)
154155
_check_type = kwargs.pop("_check_type", True)
155156
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
156157
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -169,6 +170,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
169170

170171
self._data_store = {}
171172
self._enforce_allowed_values = _enforce_allowed_values
173+
self._enforce_validations = _enforce_validations
172174
self._check_type = _check_type
173175
self._spec_property_naming = _spec_property_naming
174176
self._path_to_item = _path_to_item
@@ -191,6 +193,7 @@ def _from_openapi_data(cls: Type[T], pod, *args, **kwargs) -> T: # noqa: E501
191193
required_properties = set(
192194
[
193195
"_enforce_allowed_values",
196+
"_enforce_validations",
194197
"_data_store",
195198
"_check_type",
196199
"_spec_property_naming",
@@ -241,6 +244,7 @@ def __init__(self, pod, *args, **kwargs) -> None: # noqa: E501
241244
"""
242245

243246
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
247+
_enforce_validations = kwargs.pop("_enforce_validations", True)
244248
_check_type = kwargs.pop("_check_type", True)
245249
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
246250
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -257,6 +261,7 @@ def __init__(self, pod, *args, **kwargs) -> None: # noqa: E501
257261

258262
self._data_store = {}
259263
self._enforce_allowed_values = _enforce_allowed_values
264+
self._enforce_validations = _enforce_validations
260265
self._check_type = _check_type
261266
self._spec_property_naming = _spec_property_naming
262267
self._path_to_item = _path_to_item

pinecone/core/openapi/db_control/model/configure_index_request_spec_pod.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
144144
"""
145145

146146
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", False)
147+
_enforce_validations = kwargs.pop("_enforce_validations", False)
147148
_check_type = kwargs.pop("_check_type", True)
148149
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
149150
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -162,6 +163,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
162163

163164
self._data_store = {}
164165
self._enforce_allowed_values = _enforce_allowed_values
166+
self._enforce_validations = _enforce_validations
165167
self._check_type = _check_type
166168
self._spec_property_naming = _spec_property_naming
167169
self._path_to_item = _path_to_item
@@ -183,6 +185,7 @@ def _from_openapi_data(cls: Type[T], *args, **kwargs) -> T: # noqa: E501
183185
required_properties = set(
184186
[
185187
"_enforce_allowed_values",
188+
"_enforce_validations",
186189
"_data_store",
187190
"_check_type",
188191
"_spec_property_naming",
@@ -232,6 +235,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
232235
"""
233236

234237
_enforce_allowed_values = kwargs.pop("_enforce_allowed_values", True)
238+
_enforce_validations = kwargs.pop("_enforce_validations", True)
235239
_check_type = kwargs.pop("_check_type", True)
236240
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
237241
_path_to_item = kwargs.pop("_path_to_item", ())
@@ -248,6 +252,7 @@ def __init__(self, *args, **kwargs) -> None: # noqa: E501
248252

249253
self._data_store = {}
250254
self._enforce_allowed_values = _enforce_allowed_values
255+
self._enforce_validations = _enforce_validations
251256
self._check_type = _check_type
252257
self._spec_property_naming = _spec_property_naming
253258
self._path_to_item = _path_to_item

0 commit comments

Comments
 (0)