Skip to content

fix: distinguish RBAC 403 from 'not installed' in FluxCD provider#6126

Merged
shahargl merged 1 commit intokeephq:mainfrom
lalalic:fix/fluxcd-rbac-error-message-5393
Mar 24, 2026
Merged

fix: distinguish RBAC 403 from 'not installed' in FluxCD provider#6126
shahargl merged 1 commit intokeephq:mainfrom
lalalic:fix/fluxcd-rbac-error-message-5393

Conversation

@lalalic
Copy link
Copy Markdown
Contributor

@lalalic lalalic commented Mar 24, 2026

Summary

Fixes #5393

When a Kubernetes ServiceAccount lacks permission to read CustomResourceDefinitions (HTTP 403 Forbidden), the FluxCD provider was catching this exception generically and reporting:

"Flux CD does not appear to be installed"

This message is misleading — FluxCD is installed, but the ServiceAccount simply doesn't have the required RBAC permissions. Users end up troubleshooting a non-existent installation problem.

Root Cause

__check_flux_installed caught all exceptions with a bare except Exception, treating a 403 Forbidden the same as a 404 Not Found.

Changes

  • __check_flux_installed: Catch ApiException separately. For status 403, re-raise so the caller can distinguish permission errors from genuine absences. Other errors still return False (FluxCD not installed).
  • validate_scopes: Add an explicit except ApiException block that returns an actionable error message on 403, directing operators to add ClusterRole permissions for apiextensions.k8s.io/customresourcedefinitions.

Before / After

Scenario Before After
FluxCD installed, 403 Forbidden "Flux CD does not appear to be installed" ❌ "Insufficient RBAC permissions: ... Add ClusterRole permissions for apiextensions.k8s.io/customresourcedefinitions (get, list)" ✅
FluxCD genuinely not installed "Flux CD does not appear to be installed" ✅ unchanged ✅

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Fixes keephq#5393

When a ServiceAccount lacks permission to read CustomResourceDefinitions
(HTTP 403 Forbidden), the FluxCD provider was catching this as a generic
exception and reporting 'Flux CD does not appear to be installed' — a
misleading message that sent users down the wrong troubleshooting path.

Changes:
- __check_flux_installed: catch ApiException separately; re-raise on 403
  so the caller can distinguish permission errors from genuine absences
- validate_scopes: add an explicit ApiException catch that returns an
  actionable RBAC error message on 403, directing operators to add
  ClusterRole permissions for apiextensions.k8s.io/customresourcedefinitions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

@lalalic is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Bug Something isn't working Provider Providers related issues labels Mar 24, 2026
Copy link
Copy Markdown
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 24, 2026
@shahargl shahargl merged commit b34a4d5 into keephq:main Mar 24, 2026
17 of 18 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

👏 Well done @lalalic! Two PRs merged already! 🎉🥳

With your second PR, you're on a roll, and your contributions are already making a difference. 🌟
Looking forward to seeing even more contributions from you. See you in Slack https://slack.keephq.dev 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working lgtm This PR has been approved by a maintainer Provider Providers related issues size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: misleading FluxCD installation error in KeepHQ

2 participants