Skip to content

Fix actions listed but not executable via action_ tool#73

Merged
7tg merged 1 commit intomainfrom
fix/action-listed-but-not-found-69
Feb 8, 2026
Merged

Fix actions listed but not executable via action_ tool#73
7tg merged 1 commit intomainfrom
fix/action-listed-but-not-found-69

Conversation

@7tg
Copy link
Owner

@7tg 7tg commented Feb 8, 2026

Summary

  • Fixes Action listed by actions_ tool not found when executing via action_ tool #69 — actions listed by actions_<model> returned "not found" when executing via action_<model>
  • Root cause: handle_action iterated raw model_admin.actions and checked callable(action), which skipped string-referenced method actions (a standard Django pattern like actions = ["set_status_disabled"])
  • Replaced manual action iteration with Django's ModelAdmin.get_actions(request) which properly resolves string references, includes globally-registered actions, and filters by user permissions

Test plan

  • New test test_listed_string_action_can_be_executed reproduces the exact bug from the issue (string-referenced action listed but not executable)
  • All 379 tests pass (378 existing + 1 new)
  • Lint clean (ruff check, ruff-format, mypy all pass)

…xecution

Fixes #69 — actions listed by actions_<model> were not found when executing
via action_<model>. The root cause was that handle_action iterated the raw
model_admin.actions list and checked callable(action), which skipped
string-referenced method actions (a standard Django pattern).

Replaced manual action iteration with ModelAdmin.get_actions(request) which
properly resolves string references, includes global actions, and filters
by user permissions.
@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

self.method = "GET"
self.path = "/"
self.META = {}
self.META = {"SCRIPT_NAME": ""}
Copy link
Owner Author

Choose a reason for hiding this comment

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

why this changed?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Django's AdminSite.each_context(request) accesses request.META["SCRIPT_NAME"] directly (not .get()), which raises a KeyError when META is empty. This is reached through get_actions(request)_filter_actions_by_permissions for certain built-in actions like delete_selected. Adding SCRIPT_NAME: "" prevents that crash while keeping the request lightweight.

@7tg 7tg merged commit 7c5f563 into main Feb 8, 2026
17 checks passed
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.

Action listed by actions_ tool not found when executing via action_ tool

1 participant