Fix auth issues: child asset creation, account page access#2163
Merged
Conversation
…readcrumb test Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Flix6x
May 12, 2026 13:09
View session
Flix6x
requested changes
May 12, 2026
Contributor
Flix6x
left a comment
There was a problem hiding this comment.
Make sure to update both agent instructions and all contents of this PR in accordance with my review.
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/e5059bde-7621-45d1-a6db-bb2f0025c04d Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…review) Context: - PR #2163 reviewer (@Flix6x) requested three specific docstring improvements - Test docstrings contained 'Bug (on main)' / 'Fix:' / 'Expected: X on main, Y with fix' paragraphs describing pre-fix behaviour, which belong in commit messages not source code - Sentences were hard-wrapped mid-phrase to fit ~79 chars, making docstrings harder to read - Double spaces after punctuation appeared in docstrings despite the rule existing in AGENTS.md Change: - Added 'Docstring Style Rules' section with three enforced sub-rules: 1. No historical context ('on main', 'before/after fix') in test docstrings 2. Keep sentences on as few lines as possible; avoid mid-sentence line breaks 3. No double spaces after punctuation (mirrors AGENTS.md rule, now explicit in this agent) Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Flix6x
requested changes
May 12, 2026
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/df191792-501f-4b9e-8502-3c3ec78fa364 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
When account_id is absent from a POST /assets request body, Marshmallow does not invoke the @validates("account_id") field validator, so the inline `if account_id is not None:` guard silently skipped the permission check. Any authenticated user could create a public (account-less) asset. Fix: raise Forbidden when account_id is None and the caller is neither a site admin nor CLI. Add tests: - test_regular_user_cannot_create_public_asset - test_regular_user_cannot_create_child_of_public_asset Update AGENTS.md: auth concerns must be covered by tests, not code inspection alone. Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/b55c75f0-c9c5-4d45-9f17-4477d6cb4760 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Flix6x
approved these changes
May 13, 2026
nhoening
approved these changes
May 13, 2026
Contributor
nhoening
left a comment
There was a problem hiding this comment.
Great, thanks.
I only found a few comment lines I think should be deleted.
Signed-off-by: F.N. Claessen <claessen@seita.nl>
3 tasks
Flix6x
pushed a commit
that referenced
this pull request
May 15, 2026
…e access (#2163) * fix: auth issues for child asset creation, account page access, and breadcrumb test Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * fix: add null checks and changelog entry for auth fixes Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * fix: update changelog with correct PR number #2163 Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/bbb22573-9b83-4d71-ac1b-f8b9de70f61b Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * fix: address review comments - docstrings, changelog, None account check Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/e5059bde-7621-45d1-a6db-bb2f0025c04d Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * agents/test-specialist: enforce docstring hygiene for tests (PR #2163 review) Context: - PR #2163 reviewer (@Flix6x) requested three specific docstring improvements - Test docstrings contained 'Bug (on main)' / 'Fix:' / 'Expected: X on main, Y with fix' paragraphs describing pre-fix behaviour, which belong in commit messages not source code - Sentences were hard-wrapped mid-phrase to fit ~79 chars, making docstrings harder to read - Double spaces after punctuation appeared in docstrings despite the rule existing in AGENTS.md Change: - Added 'Docstring Style Rules' section with three enforced sub-rules: 1. No historical context ('on main', 'before/after fix') in test docstrings 2. Keep sentences on as few lines as possible; avoid mid-sentence line breaks 3. No double spaces after punctuation (mirrors AGENTS.md rule, now explicit in this agent) Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * fix: clarify public-asset comment - name schema and validator Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/df191792-501f-4b9e-8502-3c3ec78fa364 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * fix: block non-admins from creating public assets; add regression tests When account_id is absent from a POST /assets request body, Marshmallow does not invoke the @validates("account_id") field validator, so the inline `if account_id is not None:` guard silently skipped the permission check. Any authenticated user could create a public (account-less) asset. Fix: raise Forbidden when account_id is None and the caller is neither a site admin nor CLI. Add tests: - test_regular_user_cannot_create_public_asset - test_regular_user_cannot_create_child_of_public_asset Update AGENTS.md: auth concerns must be covered by tests, not code inspection alone. Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/b55c75f0-c9c5-4d45-9f17-4477d6cb4760 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> * docs: remove comments about fixes Signed-off-by: F.N. Claessen <claessen@seita.nl> --------- Signed-off-by: F.N. Claessen <claessen@seita.nl> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> Co-authored-by: F.N. Claessen <claessen@seita.nl> (cherry picked from commit 508603a) Signed-off-by: F.N. Claessen <claessen@seita.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AssetAPI.post- remove decorator, add inline permission check on parent asset or target account (+ null guard for non-existent parent)AccountCrudUI.get- addcheck_access(account, "read")before rendering (+ null guard for non-existent account)GenericAssetSchema.validate_accountexplicitly)@validates("account_id")is not called for absent fields; added explicitForbiddenfor non-admins