Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Fix error when viewing used_by for built-in source #13588

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dominic-r
Copy link
Contributor

@dominic-r dominic-r commented Mar 20, 2025

What

This PR fixes an error that occurs when trying to view the /used_by/ API endpoint for the built-in source. Previously, accessing this endpoint would raise a NotImplementedError because the built-in source doesn't properly implement the required abstract methods.

How

  • Added special handling in SerializerModel.serializer to return SourceSerializer for built-in sources
  • Added implementations for component, property_mapping_type, get_base_user_properties, and get_base_group_properties methods in the Source class that handle the built-in source case

Testing:

Confirmed the /api/v3/sources/all/authentik-built-in/used_by/ endpoint now returns a proper response instead of a 500 (I think) error

Closes #13587<!--
👋 Hi there! Welcome.

Please check the Contributing guidelines: https://docs.goauthentik.io/docs/developer-docs/#how-can-i-contribute
-->

Details

REPLACE ME


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make website)

@dominic-r dominic-r requested a review from a team as a code owner March 20, 2025 03:05
Copy link

netlify bot commented Mar 20, 2025

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit 5a05de8
🔍 Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/67e6ede2852a960008a71e21

Copy link

netlify bot commented Mar 20, 2025

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 5a05de8
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/67e6ede2b8e039000860491a
😎 Deploy Preview https://deploy-preview-13588--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.

Project coverage is 92.74%. Comparing base (608f63e) to head (5a05de8).

Files with missing lines Patch % Lines
authentik/core/models.py 0.00% 9 Missing ⚠️
authentik/lib/models.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13588      +/-   ##
==========================================
- Coverage   92.76%   92.74%   -0.03%     
==========================================
  Files         794      794              
  Lines       40577    40589      +12     
==========================================
  Hits        37643    37643              
- Misses       2934     2946      +12     
Flag Coverage Δ
e2e 47.91% <0.00%> (-0.02%) ⬇️
integration 24.27% <0.00%> (-0.01%) ⬇️
unit 90.51% <8.33%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dominic-r
Copy link
Contributor Author

what? I didn't change docs at all. Will ignore

@rissson
Copy link
Member

rissson commented Mar 20, 2025

The error you're seeing is probably a symptom of a missing UsedByMixin on a serializer. Do you know which model this is failing on?

@dominic-r
Copy link
Contributor Author

dominic-r commented Mar 26, 2025

Oh my @rissson Completly forgot to answer this. I'll push a commit which should fix this issue

@dominic-r
Copy link
Contributor Author

dominic-r commented Mar 26, 2025

Verification: cURL (GET) http://localhost:9000/api/v3/sources/all/authentik-built-in/used_by/ : [] ~ In QA: Returns a server error

@dominic-r dominic-r changed the title core: used_by: handle NotImplementedError in used_by endpoint core: Fix component method in Source class to avoid NotImplementedError Mar 26, 2025
@rissson rissson requested review from BeryJu and a team March 27, 2025 10:59
@dominic-r dominic-r changed the title core: Fix component method in Source class to avoid NotImplementedError core: Fix error when viewing used_by for built-in source Mar 28, 2025
@rissson
Copy link
Member

rissson commented Mar 28, 2025

Could we add a test for this as well? I can quickly do it if you want me to

@dominic-r
Copy link
Contributor Author

Sure, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GET /api/v3/sources/all/authentik-built-in/used_by/
2 participants