Migration guide
Every breaking release has its own section below, newest first. If you are crossing several releases at once, work from the bottom of the page upwards.
Upgrading to v0.16.0 (from v0.15.x)
0.15 0.16 pydantic.missing,pydantic.missing_argument,pydantic.missing_keyword_only_argument,pydantic.missing_positional_only_argumentfastapi-viewsets.requiredpydantic.string_too_short,pydantic.too_short,pydantic.bytes_too_short{min_length}fastapi-viewsets.min_length{minLength}pydantic.string_too_long,pydantic.too_long,pydantic.bytes_too_long,pydantic.url_too_long{max_length}fastapi-viewsets.max_length{maxLength}pydantic.greater_than_equal{ge}fastapi-viewsets.min_value{minValue}pydantic.greater_than{gt}fastapi-viewsets.min_value_exclusive{minValue}pydantic.less_than_equal{le}fastapi-viewsets.max_value{maxValue}pydantic.less_than{lt}fastapi-viewsets.max_value_exclusive{maxValue}pydantic.multiple_of{multiple_of}fastapi-viewsets.multiple_of{multipleOf}pydantic.decimal_max_digits{max_digits}fastapi-viewsets.max_digits{maxDigits}pydantic.decimal_max_places{decimal_places}fastapi-viewsets.max_decimal_places{maxDecimalPlaces}pydantic.decimal_whole_digits{whole_digits}fastapi-viewsets.max_whole_digits{maxWholeDigits}pydantic.string_pattern_mismatch{pattern}fastapi-viewsets.pattern{pattern}pydantic.enum,pydantic.literal_error{expected}fastapi-viewsets.in_allowed_values{allowedAsText}pydantic.int_type,pydantic.int_parsing,pydantic.int_parsing_size,pydantic.int_from_floatfastapi-viewsets.invalid_integerpydantic.float_*,pydantic.finite_number,pydantic.decimal_type,pydantic.decimal_parsing,pydantic.fraction_*fastapi-viewsets.invalid_numberpydantic.bool_*fastapi-viewsets.invalid_booleanpydantic.date_type,pydantic.date_parsing,pydantic.date_from_datetime_*fastapi-viewsets.invalid_datepydantic.time_type,pydantic.time_parsingfastapi-viewsets.invalid_timepydantic.datetime_type,pydantic.datetime_parsing,pydantic.datetime_object_invalid,pydantic.datetime_from_date_parsingfastapi-viewsets.invalid_datetimepydantic.time_delta_*fastapi-viewsets.invalid_durationpydantic.url_type,pydantic.url_parsing,pydantic.url_syntax_violationfastapi-viewsets.invalid_urlpydantic.uuid_type,pydantic.uuid_parsingfastapi-viewsets.invalid_uuidpydantic.date_past,pydantic.datetime_past/pydantic.date_future,pydantic.datetime_futurefastapi-viewsets.past/fastapi-viewsets.futurepydantic.string_type,pydantic.string_unicode,pydantic.bytes_type,pydantic.dict_type,pydantic.frozen_dict_type,pydantic.ordered_dict_type,pydantic.counter_type,pydantic.list_type,pydantic.tuple_type,pydantic.set_type,pydantic.frozen_set_type,pydantic.deque_type,pydantic.mapping_type,pydantic.iterable_type,pydantic.model_type,pydantic.model_attributes_type,pydantic.dataclass_type,pydantic.dataclass_exact_type,pydantic.named_tuple_type,pydantic.none_required,pydantic.arguments_type,pydantic.callable_type,pydantic.is_instance_of,pydantic.is_subclass_offastapi-viewsets.invalid_typepydantic.value_error,pydantic.assertion_error{error}fastapi-viewsets.invalid{}(the text is indetail)An error from the
invalid_*,invalid_typeorin_allowed_valuesrows with a null input becomesfastapi-viewsets.required. Other pydantic types remainpydantic.<type>.- python
settings.viewsets_tag_name = lambda cls: cls.__name__.removesuffix("ViewSet")
Upgrading to v0.15.0 (from v0.14.x)
- python
# 0.14 async def perform_destroy(self, context, pk: str) -> dict: record = await reset_setting(pk) return record.model_dump() # 0.15 @__router.post("{pk}/reset") async def reset(self, context: Context, pk: str) -> Setting: return await reset_setting(pk)tsreset(pk: string) { return this.request<Setting>('POST', `/${pk}/reset`); }See custom endpoints and TS custom endpoints.
- ts
// 0.14 await api.bulkDestroy(pks); // DestroyReturnData[]; throws on the first missing key // 0.15 const result = await api.bulkDestroy(pks); // BulkDestroyReturnData<K> const failed = Object.entries(result).filter(([, error]) => error !== null);
Upgrading to v0.14.0 (from v0.13.x)
Upgrading to v0.13.0 (from v0.12.x)
- python
# 0.12 async def setup_lookup_filter(self, fltr): self._ids = fltr.ids async def perform_lookup(self, context): return [to_item(tag) for tag in Tag.objects.filter(id__in=self._ids)] # 0.13 async def perform_lookup(self, context): return Tag.objects.all() async def apply_lookup_filter(self, context, query, records): if query.has_filter and query.fltr.ids: records = records.filter(id__in=query.fltr.ids) query.mark_applied("filter") return await super().apply_lookup_filter(context, query, records) def to_lookup_item(self, raw): return to_item(raw)
Upgrading to v0.12.0 (from v0.11.x)
0.11 0.12 not_foundfastapi-viewsets.not_foundread_onlyfastapi-viewsets.read_onlysession_expiredfastapi-viewsets.session_expirednot_authorizedfastapi-viewsets.not_authorizedrate_limitedfastapi-viewsets.rate_limitedresult_timeoutfastapi-viewsets.result_timeoutresult_reader_stoppedfastapi-viewsets.result_reader_stoppedaction_dispatch_failedfastapi-viewsets.action_dispatch_failedaction_interruptedfastapi-viewsets.action_interruptedaction_failedfastapi-viewsets.action_failedidempotency_key_invalidfastapi-viewsets.idempotency_key_invalididempotency_key_reusedfastapi-viewsets.idempotency_key_reusedunsupported_list_shapefastapi-viewsets.unsupported_list_shapeevent_topic_invalidfastapi-viewsets.event_topic_invalidevent_topic_refusedfastapi-viewsets.event_topic_refusedevent_scope_missingfastapi-viewsets.event_scope_missingevent_subscriptions_exceededfastapi-viewsets.event_subscriptions_exceededevent_cursors_exceededfastapi-viewsets.event_cursors_exceededcursor_unreadablefastapi-viewsets.cursor_unreadablecursor_missing_positionfastapi-viewsets.cursor_missing_positioncursor_stalefastapi-viewsets.cursor_stalecursor_missing_keysfastapi-viewsets.cursor_missing_keyscursor_value_mismatchfastapi-viewsets.cursor_value_mismatch
One error body
Every error of a viewset's route is answered with one body, ApiErrorBody, over REST and muxws, without a handler registered by the application (see Error codes → The error body):
{ "detail": "...", "detail_code": "<namespace>.<code>", "detail_params": {}, "field_errors": {} }- python
# before from fastapi_viewsets.exceptions import DfViewSetError, df_viewset_exception_handler app.add_exception_handler(DfViewSetError, df_viewset_exception_handler) # after from fastapi_viewsets.error_responses import install_error_handlers install_error_handlers(app) Error 0.11 body 0.12 body NotFoundError(42), handler registered{"detail": "Item with pk 42 not found", "detail_code": "not_found", "detail_params": {"pk": 42}}{"detail": "Item with pk 42 not found", "detail_code": "fastapi-viewsets.not_found", "detail_params": {"pk": 42}, "field_errors": {}}NotFoundError(42), no handler{"detail": "Item with pk 42 not found"}the same as above a request that fails validation {"detail": [{"type": "string_too_short", "loc": ["body", "name"], "msg": "String should have at least 3 characters", "input": "a", "ctx": {"min_length": 3}}]}{"detail": "The request failed validation", "detail_code": "fastapi-viewsets.validation_failed", "detail_params": {}, "field_errors": {"name": [{"code": "pydantic.string_too_short", "params": {"min_length": 3}, "detail": "String should have at least 3 characters"}]}}raise HTTPException(403, "Not your item"){"detail": "Not your item"}{"detail": "Not your item", "detail_code": "fastapi-viewsets.http_error", "detail_params": {"status": 403}, "field_errors": {}}raise HTTPException(400, {"field": "x"}){"detail": {"field": "x"}}{"detail": "Bad Request", "detail_code": "fastapi-viewsets.http_error", "detail_params": {"status": 400, "detail": {"field": "x"}}, "field_errors": {}}an exception without a handler plain text Internal Server Error{"detail": "Internal Server Error", "detail_code": "fastapi-viewsets.unhandled_error", "detail_params": {}, "field_errors": {}}a muxws command with headers no route matches {"detail": ":path must be absolute, got 'tracks'"}(400){"detail": ":path must be an absolute path", "detail_code": "fastapi-viewsets.command_invalid", "detail_params": {"reason": "path_relative"}, "field_errors": {}}(400)an exception before a muxws command's response payload null(500)the body of fastapi-viewsets.unhandled_error(500)The response of an exception without a handler no longer contains its text; the exception is re-raised and logged by the server as before. A handler the application registered for an exception class, a status,
HTTPException, orException/ 500 keeps answering as it did.- jsonc
// 0.11 {"rev": null, "events": null, "error": "fastapi-viewsets.event_topic_refused", "status": 403} // 0.12 {"rev": null, "events": null, "error": {"detail": "Topic org:9 is not admitted", "detail_code": "fastapi-viewsets.event_topic_refused", "detail_params": {"topic": "org:9"}, "field_errors": {}}, "status": 403}The event client reports it as a
ViewSetRequestErrorofstatuswhoseresponse.datais that body. Deploy the frontend and the backend together: a 0.12 event client leaves a topic answered with a code string unanswered, and a 0.11 one leaves a topic answered with a body unanswered. - ts
// before const body = error.response?.data; if (error.response?.status === 422) toFieldErrors(body as FieldErrorsBody); else if (typeof body?.detail === 'string') toErrorDescription(body as ApiErrorBody); // after const body = errorBodyOf(error); toFieldErrors(body); // {} for an error without field errors toErrorDescription(body);
Upgrading to v0.11.0 (from v0.10.x)
Upgrading to v0.10.0 (from v0.9.x)
Upgrading to v0.9.0 (from v0.8.x)
Upgrading to v0.8.0 (from v0.7.x)
The npm package no longer translates errors and no longer depends on @dynamicforms/translatable. It converts an error body into an ErrorDescription, and the application translates it by its code with the function it uses for its vue-forms errors. The response bodies are unchanged.
- ts
// before translateStrings((key) => myTranslations[key]); const message = translateApiError(body); // after const message = errorText(toErrorDescription(body));errorTextis the application's function described in vue-forms: Error messages and translation. It looks the code up in the application's translations, substitutesparamsand falls back todetail. Add the codes listed in Error codes to the translations; the placeholder names are the same.
Upgrading to v0.6.0 (from v0.5.7)
Nothing about a response body changes unless you opt in. There is no checklist for this release - see Error codes for what changed and how to opt into it.
NotFoundError moves from fastapi_viewsets.response_classes to fastapi_viewsets.exceptions:
# before
from fastapi_viewsets.response_classes import NotFoundError
# after
from fastapi_viewsets.exceptions import NotFoundError