Skip to content

Commit

Permalink
Bump axios from 0.26.1 to 0.27.2 (#3529)
Browse files Browse the repository at this point in the history
* Bump axios from 0.26.1 to 0.27.2

Bumps [axios](https://github.com/axios/axios) from 0.26.1 to 0.27.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v0.26.1...v0.27.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update types on axios error paths

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Todd Schiller <todd.schiller@gmail.com>
  • Loading branch information
dependabot[bot] and twschiller committed May 30, 2022
1 parent a3ed0fb commit 33cbffb
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 49 deletions.
75 changes: 46 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@xobotyi/scrollbar-width": "^1.9.5",
"ace-builds": "^1.4.12",
"autocompleter": "^6.1.2",
"axios": "^0.26.0",
"axios": "^0.27.2",
"bootstrap": "^4.6.0",
"bootstrap-icons": "^1.5.0",
"bootstrap-switch-button-react": "^1.2.0",
Expand Down
20 changes: 15 additions & 5 deletions src/auth/ScopeSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import Form, {
RenderBody,
RenderSubmit,
} from "@/components/form/Form";
import { isSingleObjectBadRequestError } from "@/types/errorContract";
import { FormikErrors } from "formik";

interface Profile {
type Profile = {
scope: string | null;
}
};

const SCOPE_REGEX = /^@[\da-z~-][\d._a-z~-]*$/;

Expand Down Expand Up @@ -84,9 +86,17 @@ const ScopeSettings: React.VoidFunctionComponent<ScopeSettingsProps> = ({
}

case StatusCodes.BAD_REQUEST: {
helpers.setErrors(
mapValues(error.response.data, (xs) => castArray(xs)[0])
);
if (isSingleObjectBadRequestError(error)) {
helpers.setErrors(
mapValues(
error.response.data,
(xs) => castArray(xs)[0]
) as FormikErrors<Profile>
);
} else {
notify.error({ message: "Error updating account alias", error });
}

return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/options/pages/blueprints/modals/ConvertToRecipeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from "@/types/helpers";
import { pick } from "lodash";
import Form from "@/components/form/Form";
import { getErrorMessage, isAxiosError } from "@/errors";
import { getErrorMessage } from "@/errors";
import { appApi, useCreateRecipeMutation } from "@/services/api";
import {
RecipeDefinition,
Expand All @@ -47,6 +47,7 @@ import { FieldDescriptions } from "@/utils/strings";
import RegistryIdWidget from "@/components/form/widgets/RegistryIdWidget";
import { StylesConfig } from "react-select";
import { RequireScope } from "@/auth/RequireScope";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

type ConvertInstallableFormState = {
blueprintId: RegistryId;
Expand Down Expand Up @@ -169,7 +170,7 @@ const ConvertToRecipeModal: React.FunctionComponent = () => {
})
);
} catch (error) {
if (isAxiosError(error) && error.response.data.config) {
if (isSingleObjectBadRequestError(error) && error.response.data.config) {
helpers.setStatus(error.response.data.config);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { blueprintModalsSlice } from "@/options/pages/blueprints/modals/blueprin
import * as Yup from "yup";
import { sortBy } from "lodash";
import Form from "@/components/form/Form";
import { getErrorMessage, isAxiosError } from "@/errors";
import { getErrorMessage } from "@/errors";
import {
appApi,
useGetEditablePackagesQuery,
Expand All @@ -51,6 +51,7 @@ import BootstrapSwitchButton from "bootstrap-switch-button-react";
import { selectAuth } from "@/auth/authSelectors";
import { Organization, UserRole } from "@/types/contract";
import Loading from "./Loading";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

type ShareInstallableFormState = {
public: boolean;
Expand Down Expand Up @@ -115,7 +116,7 @@ const ShareRecipeModal: React.FunctionComponent = () => {
closeModal();
dispatch(appApi.util.invalidateTags(["Recipes"]));
} catch (error) {
if (isAxiosError(error) && error.response.data.config) {
if (isSingleObjectBadRequestError(error) && error.response.data.config) {
helpers.setStatus(error.response.data.config);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/options/pages/brickEditor/useSubmitBrick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import useReinstall from "@/options/pages/blueprints/utils/useReinstall";
import notify from "@/utils/notify";
import { reportEvent } from "@/telemetry/events";
import { getLinkedApiClient } from "@/services/apiClient";
import { isAxiosError } from "@/errors";
import {
clearServiceCache,
reactivateEveryTab,
} from "@/background/messenger/api";
import { loadBrickYaml } from "@/runtime/brickYaml";
import { PackageUpsertResponse } from "@/types/contract";
import { appApi } from "@/services/api";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

type SubmitOptions = {
create: boolean;
Expand Down Expand Up @@ -145,7 +145,7 @@ function useSubmitBrick({
} catch (error) {
console.debug("Got validation error", error);

if (isAxiosError(error)) {
if (isSingleObjectBadRequestError(error)) {
for (const message of castArray(error.response.data.__all__ ?? [])) {
notify.error(message);
}
Expand All @@ -156,7 +156,7 @@ function useSubmitBrick({
}
}
},
[history, refresh, reinstall, url, create]
[dispatch, history, refresh, reinstall, url, create]
);

return { submit, validate, remove: create ? null : remove };
Expand Down
6 changes: 4 additions & 2 deletions src/pageEditor/hooks/useCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { editorSlice } from "@/pageEditor/slices/editorSlice";
import { useDispatch, useSelector } from "react-redux";
import { useCallback } from "react";
import notify from "@/utils/notify";
import { getErrorMessage, isAxiosError } from "@/errors";
import { getErrorMessage } from "@/errors";
import blockRegistry from "@/blocks/registry";
import extensionPointRegistry from "@/extensionPoints/registry";
import { ADAPTERS } from "@/pageEditor/extensionPoints/adapter";
Expand All @@ -37,6 +37,7 @@ import extensionsSlice from "@/store/extensionsSlice";
import { selectSessionId } from "@/pageEditor/slices/sessionSelectors";
import { FormState } from "@/pageEditor/pageEditorTypes";
import { isInnerExtensionPoint } from "@/registry/internal";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

const { saveExtension } = extensionsSlice.actions;
const { markSaved } = editorSlice.actions;
Expand All @@ -59,8 +60,9 @@ async function upsertConfig(

function selectErrorMessage(error: unknown): string {
// FIXME: should this logic be in getErrorMessage?
if (isAxiosError(error)) {
if (isSingleObjectBadRequestError(error)) {
return (
// FIXME: won't the data on each property be an array?
error.response?.data.config?.toString() ??
error.response?.statusText ??
"No response from PixieBrix server"
Expand Down
7 changes: 5 additions & 2 deletions src/pageEditor/sidebar/AddToRecipeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import Form, {
RenderBody,
RenderSubmit,
} from "@/components/form/Form";
import { isAxiosError } from "@/errors";
import { object, string } from "yup";
import RadioItemListWidget from "@/components/form/widgets/radioItemList/RadioItemListWidget";
import { RadioItem } from "@/components/form/widgets/radioItemList/radioItemListWidgetTypes";
import useRemoveExtension from "@/pageEditor/hooks/useRemoveExtension";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

type FormState = {
recipeId: RegistryId;
Expand Down Expand Up @@ -105,7 +105,10 @@ const AddToRecipeModal: React.VFC = () => {

hideModal();
} catch (error: unknown) {
if (isAxiosError(error) && error.response.data.config) {
if (
isSingleObjectBadRequestError(error) &&
error.response.data.config
) {
helpers.setStatus(error.response.data.config);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/sidebar/CreateRecipeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import Form, {
import { useCreateRecipeMutation, useGetRecipesQuery } from "@/services/api";
import useCreate from "@/pageEditor/hooks/useCreate";
import extensionsSlice from "@/store/extensionsSlice";
import { isAxiosError } from "@/errors";
import notify from "@/utils/notify";
import ConnectedFieldTemplate from "@/components/form/ConnectedFieldTemplate";
import { produce } from "immer";
Expand All @@ -67,6 +66,7 @@ import useRemoveExtension from "@/pageEditor/hooks/useRemoveExtension";
import useRemoveRecipe from "@/pageEditor/hooks/useRemoveRecipe";
import RegistryIdWidget from "@/components/form/widgets/RegistryIdWidget";
import { generateRecipeId } from "@/utils/recipeUtils";
import { isSingleObjectBadRequestError } from "@/types/errorContract";

const { actions: optionsActions } = extensionsSlice;

Expand Down Expand Up @@ -337,7 +337,7 @@ const CreateRecipeModal: React.VFC = () => {

hideModal();
} catch (error) {
if (isAxiosError(error) && error.response.data.config) {
if (isSingleObjectBadRequestError(error) && error.response.data.config) {
helpers.setStatus(error.response.data.config);
return;
}
Expand Down
Loading

0 comments on commit 33cbffb

Please sign in to comment.