fix: OIDC login crash when a Keycloak group name collides with an exi… - #32
Conversation
…sting Plone user id
📝 WalkthroughWalkthroughAdds a ChangesGroup sync collision fix
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant OIDCLogin
participant KimugPlugin
participant PloneGroupAPI
OIDCLogin->>KimugPlugin: _create_update_groups(user, token groups)
KimugPlugin->>PloneGroupAPI: remove stale group memberships
KimugPlugin->>PloneGroupAPI: api.group.create(missing group id)
PloneGroupAPI-->>KimugPlugin: None (id collision with user)
KimugPlugin->>KimugPlugin: log warning, skip group
KimugPlugin->>PloneGroupAPI: api.group.create(real-group)
PloneGroupAPI-->>KimugPlugin: group object
KimugPlugin->>PloneGroupAPI: join user to real-group
KimugPlugin-->>OIDCLogin: user.getGroups()
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pas/plugins/kimug/plugin/__init__.py (1)
143-192: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGuard logic is correct; note the duplication risk with upstream.
The
None-check correctly prevents theAttributeErrorcrash on id collisions, and the test confirms the expected behavior (skip colliding group, still create/join non-colliding ones).The one thing worth flagging: this override re-implements the entire upstream
_create_update_groupsbody rather than delegating to it, so any future behavioral change inpas.plugins.oidc's implementation (e.g. new group properties, different removal semantics) will silently diverge from this fork unless someone remembers to resync it manually. Consider adding a short comment noting the coupling to the specific upstream version, or a test that pins/exercises the pieces this override intentionally mirrors, so a future upstream upgrade doesn't quietly regress.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pas/plugins/kimug/plugin/__init__.py` around lines 143 - 192, The override in `_create_update_groups` duplicates the upstream `OIDCPlugin._create_update_groups` implementation, so it can silently drift from future `pas.plugins.oidc` behavior. Add a short note near `_create_update_groups` (or a focused test around this method) that explicitly documents the dependency on the current upstream implementation and the parts intentionally mirrored, so future upgrades of `OIDCPlugin` can be checked against this forked logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/pas/plugins/kimug/plugin/__init__.py`:
- Around line 143-192: The override in `_create_update_groups` duplicates the
upstream `OIDCPlugin._create_update_groups` implementation, so it can silently
drift from future `pas.plugins.oidc` behavior. Add a short note near
`_create_update_groups` (or a focused test around this method) that explicitly
documents the dependency on the current upstream implementation and the parts
intentionally mirrored, so future upgrades of `OIDCPlugin` can be checked
against this forked logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0588be7c-4742-40fb-a1be-b17ac879467c
📒 Files selected for processing (3)
CHANGES.mdsrc/pas/plugins/kimug/plugin/__init__.pytests/plugin/test_plugin.py
…sting Plone user id
Summary by CodeRabbit
Bug Fixes
Tests
Documentation