Repository navigation
fix(admin-ui): replace explicit catch (error: any) with proper types - #47397
Merged
Merged
Conversation
Contributor
Author
edewit
approved these changes
Mar 24, 2026
Contributor
Author
Remove all explicit `: any` annotations from catch clauses in the Admin UI. Since TypeScript's `strict` mode (with `useUnknownInCatchVariables`) already types catch variables as `unknown`, the explicit `: any` annotations were unnecessarily bypassing type safety. For catch blocks that only pass the error to `addError()` (which accepts `unknown`), the fix is simply removing the `: any` annotation. For two catch blocks that performed unsafe property access on the error (`error.response?.data?.errorMessage`), the fix replaces: - `CreateFlow.tsx`: use `addError()` instead of manual message extraction (consistent with the rest of the codebase) - `ClientScopesSection.tsx`: use `getErrorMessage()` from `@keycloak/keycloak-ui-shared` for type-safe error formatting Closes #17771 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
ahus1
requested changes
Apr 10, 2026
Member
There was a problem hiding this comment.
@pierluigilenoci - the linting fails, please fix. You can run the builds in your cloned repository to verify that they succeed.
@edewit - before approving PRs, please verify the CI buillds. If the CI builds didn't run for a first-time contributor, contact someone in your team that can approve them.
Contributor
Author
|
@ahus1 Thank you for the review — I'll investigate the linting failure and push a fix. Apologies for the oversight. |
Collapse multi-line console.warn arguments onto a single line in ClientScopesSection.tsx to fix the prettier/prettier lint error. Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Contributor
Author
|
Fixed the linting issue — the |
Closed
sashyo
pushed a commit
to tide-foundation/keycloak-IGA
that referenced
this pull request
Jul 20, 2026
keycloak#47397) Remove all explicit `: any` annotations from catch clauses in the Admin UI. Since TypeScript's `strict` mode (with `useUnknownInCatchVariables`) already types catch variables as `unknown`, the explicit `: any` annotations were unnecessarily bypassing type safety. For catch blocks that only pass the error to `addError()` (which accepts `unknown`), the fix is simply removing the `: any` annotation. For two catch blocks that performed unsafe property access on the error (`error.response?.data?.errorMessage`), the fix replaces: - `CreateFlow.tsx`: use `addError()` instead of manual message extraction (consistent with the rest of the codebase) - `ClientScopesSection.tsx`: use `getErrorMessage()` from `@keycloak/keycloak-ui-shared` for type-safe error formatting Closes keycloak#17771 Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove all explicit
: anyannotations from catch clauses in the Admin UI, replacing them with proper type-safe error handling.Since TypeScript's
strictmode (withuseUnknownInCatchVariables) already types catch variables asunknown, the explicit: anyannotations were unnecessarily bypassing type safety.Changes
7 catch blocks — simple removal of
: any(error is only passed toaddError(), which acceptsunknown):FlowDetails.tsx(2 catch blocks)PasswordPolicy.tsxAddKubernetesConnect.tsxAddJWTAuthorizationGrant.tsxAddSamlConnect.tsxAddSpiffeConnect.tsx2 catch blocks — replaced unsafe property access with type-safe utilities:
CreateFlow.tsx: replacederror.response?.data?.errorMessage || errorwithaddError()(consistent with rest of codebase)ClientScopesSection.tsx: replacederror.response?.data?.errorMessage || errorwithgetErrorMessage()from@keycloak/keycloak-ui-sharedAfter this change, zero
catch (error: any)remain in the entire JS monorepo.Closes #17771