fix: handle missing sso provider configuration on settings pages #132

Merged
forgejo-bot merged 1 commit from bug/34 into main 2026-10-10 20:55:13 +00:00
Owner

Problem

GlitchTip reported a NoMethodError: undefined method 'keys' for nil in render_sso_providers (app/views/settings/security/edit.rb) – reported as hobbypunk/centinel#34.

Configurations.auth.providers is nil when no SSO providers are configured (e.g. Centinel runs proxy auth only). While the home page and the OmniAuth initializer already guard with key?(:providers), both settings pages accessed providers unguarded. config/settings/test.yml even documented the crash („Settings pages crash with nil.providers") and masked it in the test env with a workaround instead of a fix.

Changes

  • app/views/settings/security/edit.rb: render_sso_providers returns early when auth.providers is missing or empty, and only renders identities of still-configured providers – this also fixes the adjacent crash when a provider was removed from the config while user identities remain.
  • app/views/settings/profile/edit.rb: translate_avatar_type accesses auth.providers nil-safely.
  • app/models/user/profile.rb: avatar_types filters identity providers that are not (anymore) in auth.providers – rendered avatar options and the avatar_type inclusion validation stay consistent with the configuration.
  • Regression tests for all three scenarios (verified to fail against the old code with exactly the reported NoMethodError).
  • config/settings/test.yml: removed the now-obsolete crash remark from the comment.

Closes hobbypunk/centinel#34

## Problem GlitchTip reported a `NoMethodError: undefined method 'keys' for nil` in `render_sso_providers` (app/views/settings/security/edit.rb) – reported as hobbypunk/centinel#34. `Configurations.auth.providers` is `nil` when no SSO providers are configured (e.g. Centinel runs proxy auth only). While the home page and the OmniAuth initializer already guard with `key?(:providers)`, both settings pages accessed `providers` unguarded. `config/settings/test.yml` even documented the crash („Settings pages crash with nil.providers") and masked it in the test env with a workaround instead of a fix. ## Changes - `app/views/settings/security/edit.rb`: `render_sso_providers` returns early when `auth.providers` is missing or empty, and only renders identities of still-configured providers – this also fixes the adjacent crash when a provider was removed from the config while user identities remain. - `app/views/settings/profile/edit.rb`: `translate_avatar_type` accesses `auth.providers` nil-safely. - `app/models/user/profile.rb`: `avatar_types` filters identity providers that are not (anymore) in `auth.providers` – rendered avatar options and the `avatar_type` inclusion validation stay consistent with the configuration. - Regression tests for all three scenarios (verified to fail against the old code with exactly the reported NoMethodError). - `config/settings/test.yml`: removed the now-obsolete crash remark from the comment. Closes hobbypunk/centinel#34
fix: handle missing sso provider configuration on settings pages
All checks were successful
PR Triage / Triage pull request (pull_request) Successful in 0s
PR Triage / Triage pull request-1 (pull_request) Successful in 38s
CI / Quality / RuboCop (pull_request) Successful in 1m20s
CI / Quality / Brakeman (pull_request) Successful in 1m22s
CI / Quality / Bundler Audit (pull_request) Successful in 1m23s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Successful in 1m48s
CI / Tests / System (pull_request) Successful in 1m54s
CI / Tests / Coverage (pull_request) Successful in 27s
CI / Tests (pull_request) Successful in 0s
CI / Container / Build and push (pull_request) Successful in 38s
CI / Container (pull_request) Successful in 0s
CI / Deploy (pull_request) Has been skipped
b855be32cd
---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
forgejo-bot scheduled this pull request to auto merge when all checks succeed 2026-10-10 20:53:35 +00:00

📊 Coverage

Metrik Abdeckung
Zeilen 98.14% (2638/2688)
Branches 82.58% (654/792)
Methoden 97.42% (416/427)

Patch-Coverage: 100.0% (11/11 geänderte Zeilen)

Geänderte Dateien (schwach zuerst)

Datei Patch-Coverage Fehlende Zeilen
app/views/settings/security/edit.rb 100.0% (6/6)
app/models/user/profile.rb 100.0% (3/3)
app/views/settings/profile/edit.rb 100.0% (2/2)

Schwächste Dateien im Projekt

Datei Abdeckung
app/components/form/select.rb 72.41%
app/components/layout/flash.rb 84.0%
app/components/concerns/actionable.rb 86.67%
app/components/layout/sidebar.rb 89.47%
app/components/concerns/inferrable.rb 90.63%
app/models/concerns/has_uuid_v7.rb 90.91%
app/components/users/avatar.rb 91.23%
app/controllers/settings/security/otps_controller.rb 91.67%
app/components/base.rb 92.16%
app/controllers/settings/security/passkeys_controller.rb 92.31%

🔍 Report im Browser ansehen · 📄 Run-Artifact „coverage-report“

<!-- coverage-report --> ## 📊 Coverage | Metrik | Abdeckung | |---|---| | Zeilen | 98.14% (2638/2688) | | Branches | 82.58% (654/792) | | Methoden | 97.42% (416/427) | **Patch-Coverage**: 100.0% (11/11 geänderte Zeilen) **Geänderte Dateien (schwach zuerst)** | Datei | Patch-Coverage | Fehlende Zeilen | |---|---|---| | app/views/settings/security/edit.rb | 100.0% (6/6) | | | app/models/user/profile.rb | 100.0% (3/3) | | | app/views/settings/profile/edit.rb | 100.0% (2/2) | | **Schwächste Dateien im Projekt** | Datei | Abdeckung | |---|---| | app/components/form/select.rb | 72.41% | | app/components/layout/flash.rb | 84.0% | | app/components/concerns/actionable.rb | 86.67% | | app/components/layout/sidebar.rb | 89.47% | | app/components/concerns/inferrable.rb | 90.63% | | app/models/concerns/has_uuid_v7.rb | 90.91% | | app/components/users/avatar.rb | 91.23% | | app/controllers/settings/security/otps_controller.rb | 91.67% | | app/components/base.rb | 92.16% | | app/controllers/settings/security/passkeys_controller.rb | 92.31% | [🔍 Report im Browser ansehen](https://pages.hoppe-dev.eu/hobbypunk-rails-base_app/pr-132/coverage) · [📄 Run-Artifact „coverage-report“](https://code.hoppe-dev.eu/hobbypunk/rails-base_app/actions/runs/2575/artifacts/coverage-report)
forgejo-bot deleted branch bug/34 2026-10-10 20:55:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hobbypunk/rails-base_app!132
No description provided.