Skip to content

fix(api): interpolate %(verbose_name_plural)s in action labels#204

Merged
MartinCastroAlvarez merged 1 commit into
mainfrom
fix/action-label-235427
May 26, 2026
Merged

fix(api): interpolate %(verbose_name_plural)s in action labels#204
MartinCastroAlvarez merged 1 commit into
mainfrom
fix/action-label-235427

Conversation

@MartinCastroAlvarez
Copy link
Copy Markdown
Owner

Bug: the Actions dropdown showed "Delete selected %(verbose_name_plural)s" — actions_payload surfaced Django's raw short_description format string without interpolating it (Django does this via model_format_dict at render time). Now raw_label % model_format_dict(model._meta) with a try/except fallback (never 500s). Test added. Tier 3, isolated label fix; test_actions + lint pass.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Django's built-in `delete_selected` (and any action whose
`short_description` uses the admin's `%(verbose_name)s` /
`%(verbose_name_plural)s` placeholders) ships a *format string* that
Django interpolates at render time via `model_format_dict(opts)`. The
SPA's `actions_payload` surfaced it raw, so the Actions dropdown showed
"Delete selected %(verbose_name_plural)s" instead of "Delete selected
files".

`actions_payload` now runs the label through `raw_label % fmt` where
`fmt = model_format_dict(model._meta)`, with a try/except that surfaces
the label verbatim for non-format strings / unknown keys (never 500s).

Test: `test_delete_selected_label_is_interpolated` — the delete_selected
label contains no `%(` placeholder and includes the model plural.

Repo-owner report ("what is verbose names?" — the raw placeholder leaked
to the UI).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner Author

@MartinCastroAlvarez MartinCastroAlvarez left a comment

Choose a reason for hiding this comment

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

Security lane: Approve. Pure label-formatting fix — interpolates Django action format strings via model_format_dict; try/except never 500s; no security/permission surface. Test added; isolated. APPROVE.

Copy link
Copy Markdown
Owner Author

@MartinCastroAlvarez MartinCastroAlvarez left a comment

Choose a reason for hiding this comment

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

Architect lane: Approve. Pure label-formatting fix — interpolates Django action format strings via model_format_dict; try/except never 500s; no security/permission surface. Test added; isolated. APPROVE.

@MartinCastroAlvarez MartinCastroAlvarez merged commit 2d388f3 into main May 26, 2026
2 checks passed
@MartinCastroAlvarez MartinCastroAlvarez deleted the fix/action-label-235427 branch May 26, 2026 21:54
MartinCastroAlvarez pushed a commit that referenced this pull request May 26, 2026
Ships the batch merged since 0.2.0a2:
- SECURITY: SW message-handler origin check (#208, CodeQL
  js/missing-origin-check) — the artifact's service worker now
  rejects cross-origin cache-control messages.
- PWA backend serving (#200), React login form end-to-end (#190),
  create/Add form completing CRUD (#199), autocomplete FK widget
  (#207), date_hierarchy drill-down (#205), action-label + list
  cosmetics fixes (#203/#204), lint cleanup (#202).

368 tests pass. Tier 6 — version bump; publish via the Security
deploy-gate under the standing "deploy regularly if secure" directive.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
MartinCastroAlvarez added a commit that referenced this pull request May 26, 2026
Ships the batch merged since 0.2.0a2:
- SECURITY: SW message-handler origin check (#208, CodeQL
  js/missing-origin-check) — the artifact's service worker now
  rejects cross-origin cache-control messages.
- PWA backend serving (#200), React login form end-to-end (#190),
  create/Add form completing CRUD (#199), autocomplete FK widget
  (#207), date_hierarchy drill-down (#205), action-label + list
  cosmetics fixes (#203/#204), lint cleanup (#202).

368 tests pass. Tier 6 — version bump; publish via the Security
deploy-gate under the standing "deploy regularly if secure" directive.

Co-authored-by: Martin Castro Laminrs <mcastro@laminr.ai>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants