Repository navigation
Conversation
Contributor
Author
|
@ahus1 @edewit This is a redo of #47408, which was closed due to CI failures. All issues from the previous attempt have been addressed:
Ready for review. Thanks for the feedback on the previous PR. |
3 tasks
Contributor
Author
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.ResetPasswordTest#resetPasswordWithLengthPasswordPolicyKeycloak CI - Forms IT (chrome) |
Enable the rule (previously "off") and fix all violations across the JS
workspace. The core change makes RealmContext.realmRepresentation
non-optional — guarded by the existing KeycloakSpinner in the provider —
allowing ~30 downstream consumers to drop redundant optional chains.
Where TypeScript types declare a value as non-nullable but runtime
behaviour can still produce undefined/null (API responses, react-hook-form
dynamic values, route params present on one route but not another, array
index access, DOM queries), the existing guards are preserved with
eslint-disable-next-line comments explaining the rationale.
Additional fixes surfaced during this work:
- PermissionConfigurationDetails: fix spinner blocking the "create
permission" form by distinguishing "loading" (null) from "new" ({})
- ResourceType: restore resourceIds?.some() guard — form.getValues
returns undefined when the field has no default value
- clients.ts createOrUpdatePolicy: narrow catch to 404 NetworkError
only instead of swallowing all errors
Closes #17770
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Contributor
Author
|
Hi — friendly follow-up. CI is green (all 84 checks passing) and the branch is up to date. Would you be able to review when you get a chance? Thank you! |
edewit
approved these changes
May 12, 2026
Closed
sashyo
pushed a commit
to tide-foundation/keycloak-IGA
that referenced
this pull request
Jul 20, 2026
…oak#48218) Enable the rule (previously "off") and fix all violations across the JS workspace. The core change makes RealmContext.realmRepresentation non-optional — guarded by the existing KeycloakSpinner in the provider — allowing ~30 downstream consumers to drop redundant optional chains. Where TypeScript types declare a value as non-nullable but runtime behaviour can still produce undefined/null (API responses, react-hook-form dynamic values, route params present on one route but not another, array index access, DOM queries), the existing guards are preserved with eslint-disable-next-line comments explaining the rationale. Additional fixes surfaced during this work: - PermissionConfigurationDetails: fix spinner blocking the "create permission" form by distinguishing "loading" (null) from "new" ({}) - ResourceType: restore resourceIds?.some() guard — form.getValues returns undefined when the field has no default value - clients.ts createOrUpdatePolicy: narrow catch to 404 NetworkError only instead of swallowing all errors Closes keycloak#17770 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@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
Enable the
@typescript-eslint/no-unnecessary-conditionESLint rule (previously"off") and fix all violations acrossjs/.Core approach: make
RealmContext.realmRepresentationnon-optional (guarded by the existing<KeycloakSpinner />in the provider), allowing ~30 downstream consumers to drop redundant?.chains.Changes include:
?.) on non-nullish values??) on non-nullable expressionsifconditions and dead code from always-falsy branchesbreadcrumbfrom route object intohandle(required by the type after removing optional access)undefined(not[]) where needed to distinguish "not loaded" from "loaded but empty" (UserCredentials,KeysListTab,Organizations).some()abuse with.forEach()inagent.tscreateOrUpdatePolicycatch to only handle 404NetworkError(previously swallowed all errors)Runtime guards preserved with
eslint-disablecomments where TypeScript types say non-nullable but runtime disagrees (17 sites total — API responses, react-hook-form dynamic values, route params missing on certain routes, array index access, DOM queries).Additional fixes surfaced during this work:
PermissionConfigurationDetails: fix spinner blocking the "create permission" form by distinguishing "loading existing" (null) from "creating new" ({})ResourceType.tsx: restoreresourceIds?.some()guard —form.getValues("resources")returnsundefinedwhen the form field has no default, causing a crash when selecting a resource type in the search dropdownclients.ts: narrow overly broadcatchincreateOrUpdatePolicyto 404 onlyCloses #17770
AI disclosure: Developed with the assistance of an AI coding agent. All changes were manually reviewed and validated.
Test plan
pnpm eslint— 0 violations forno-unnecessary-condition