Skip to content

Conversation

ywzheng1
Copy link
Member

@ywzheng1 ywzheng1 commented Sep 2, 2025

What is this feature?

  • Bugfix when user has No basic role assigned, they are seeing infinite api calls to /settings endpoint.

Root cause:

  • The provisioning settings endpoint returns 403 for users without any role. RTK Query treats 403 as an error (not a fulfilled, cacheable result), so every mount/re-render re-subscribes and re-requests.
  • BrowseDashboardsPage has multiple subscribers (e.g., BrowseView → DashboardsTree → NameCell → FolderRepo), which ends up in an apparent “infinite” call pattern.
  • Adding a “no role” check gates the settings query (skip when the user has no role), preventing the error state from being re-subscribed to and eliminating the repeated requests.
image

Why do we need this feature?

  • Prevent user browser crash

Who is this feature for?

  • No basic role user

Which issue(s) does this PR fix?:

Fixes https://github.com/grafana/git-ui-sync-project/issues/474

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@ywzheng1 ywzheng1 self-assigned this Sep 2, 2025
@ywzheng1 ywzheng1 added area/frontend no-changelog Skip including change in changelog/release notes labels Sep 2, 2025
@ywzheng1 ywzheng1 marked this pull request as ready for review September 2, 2025 21:36
@ywzheng1 ywzheng1 requested review from a team as code owners September 2, 2025 21:36
@github-actions github-actions bot added this to the 12.2.x milestone Sep 2, 2025
Comment on lines +9 to +12
const hasNoRole = contextSrv.user.orgRole === OrgRole.None;
const skip = !config.featureToggles.provisioning || hasNoRole;

const settingsQuery = useGetFrontendSettingsQuery(settings || skip ? skipToken : undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the same check to BrowseView, so we don't call the /settings endpoint for users without a role?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added 👍🏻

Comment on lines 22 to 25
!folder ||
Boolean('parentUID' in folder && folder.parentUID) ||
folder.managedBy !== ManagerKind.Repo ||
isProvisionedInstance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think the list of conditions is getting large enough to be extracted into a function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good callout, moved into separate func

@ywzheng1 ywzheng1 merged commit 3a3ea45 into main Sep 3, 2025
102 checks passed
@ywzheng1 ywzheng1 deleted the ywzheng1/provision-endpoints-no-role-user-fix branch September 3, 2025 14:17
// Skip render if parentUID is present, then we should skip rendering. we only display icon for root folders
const hasParent = folder && Boolean('parentUID' in folder && folder.parentUID);
// Skip render if folder is not managed by Repo
const isNotManaged = folder && folder.managedBy !== ManagerKind.Repo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that #110467 is no longer needed, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sorry! I meant to comment in your PR when I returned from doc appointment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants