Skip to content

Add the task dashboard's admin guard only once, so the docs build and a second app in the same process work again - #2896

Merged
Flix6x merged 3 commits into
mainfrom
fix/rq-dashboard-hook-once
Nov 23, 2026
Merged

Flix6x merged 3 commits into
mainfrom
fix/rq-dashboard-hook-once

Conversation

@Flix6x

@Flix6x Flix6x commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Description

Every Read the Docs build has failed since v1.1.2 and v1.0.3, including stable, so the published docs do not show these releases yet.

The documentation build creates a FlexMeasures app once per API page (autoflask).
Since the security release, every app adds its admin guard to rq_dashboard's shared blueprint (5a021dd, which made the task dashboard admin-only in every environment).
Flask refuses new hooks on a blueprint that is already registered, so the second app fails with:

AssertionError: The setup method 'before_request' can no longer be called on the blueprint 'rq_dashboard'. It has already been registered at least once, any changes will not be applied consistently.

The same happens to any script or test suite that creates a second app in one process.

  • The guard is now a module-level function, rq_dashboard_admin_auth, and is added to the blueprint only once, before the first registration. The dashboard stays admin-only in every environment.
  • A regression test registers the dashboard a second time, after the test app has registered it, and checks there is still exactly one guard.

No changelog entry: released servers are not affected, as each process creates one app.

How to test

  • pytest flexmeasures/ui/tests/test_tasks_access.py. Without the change in flexmeasures/ui/__init__.py, the new test fails with the error above.
  • Build the docs as Read the Docs does: cd documentation && python -m sphinx -T -W --keep-going -b html -d _build/doctrees -D language=en . _build/html. It fails on main and passes on this branch.

Checklist

  • Added changelog item in documentation/changelog.rst (not needed, see above)

🤖 Generated with Claude Code

Flix6x and others added 2 commits November 23, 2026 16:29
…e same process can start

The documentation build creates an app per API page, and the security release made every app add its guard to rq_dashboard's shared blueprint (5a021dd).
Flask refuses new hooks on a blueprint that is already registered, so every docs build has failed since v1.1.2 and v1.0.3, and so does any script or test suite that creates a second app.
The guard now lives at module level and is added before the first registration only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x added a commit that referenced this pull request Nov 23, 2026
… a second app in the same process can start (#2896)

The documentation build creates an app per API page, and the security release made every app add its guard to rq_dashboard's shared blueprint (5a021dd).
Flask refuses new hooks on a blueprint that is already registered, so every docs build has failed since v1.1.2, and so does any script or test suite that creates a second app.
The guard now lives at module level and is added before the first registration only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x self-assigned this Nov 23, 2026
@Flix6x Flix6x added documentation Improvements or additions to documentation bug Something isn't working labels Nov 23, 2026
@Flix6x Flix6x added this to the 1.2.0 milestone Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x
Flix6x merged commit 4ebd392 into main Nov 23, 2026
11 checks passed
@Flix6x
Flix6x deleted the fix/rq-dashboard-hook-once branch November 23, 2026 18:55
Flix6x added a commit that referenced this pull request Nov 23, 2026
… a second app in the same process can start (#2896)

The documentation build creates an app per API page, and the security release made every app add its guard to rq_dashboard's shared blueprint.
Flask refuses new hooks on a blueprint that is already registered, so docs builds have failed since v1.0.3, and so does any script or test suite that creates a second app.
The guard now lives at module level and is added before the first registration only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
BelhsanHmida added a commit that referenced this pull request Nov 23, 2026
Brings in #2896, which fixes the docs build that the security release broke.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
BelhsanHmida added a commit that referenced this pull request Nov 23, 2026
Brings in #2896, which adds the task dashboard's admin guard only once, so the docs build works again.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant