Skip to content

Ask for a profile's permissions instead of letting the database refuse them - #736

Merged
blaipr merged 1 commit into
mainfrom
fix/profile-requires-its-permissions
Aug 13, 2026
Merged

Ask for a profile's permissions instead of letting the database refuse them#736
blaipr merged 1 commit into
mainfrom
fix/profile-requires-its-permissions

Conversation

@blaipr

@blaipr blaipr commented Aug 13, 2026

Copy link
Copy Markdown
Member

The bug

A profile is its permissions, and the column holding them is NOT NULL — but the API read them as optional (getParamString('profile'), no required flag).

So a caller who left them out got the database's integrity error back: a 500 saying nothing about which parameter was missing, on an endpoint where every other missing parameter answers with a 400 that names the problem.

The fix

Required on create and edit both.

The edit case is the worse of the two: dropping the permissions from an edit would have blanked them on a profile that people are already assigned to — taking access away from everybody holding it, rather than merely failing to create something.

Testing

The test that recorded the old integrity error as the behaviour now asserts the refusal, and the edit case gains one of its own.

Integration: 12 green in the class. Unit: 6 green on the profile controllers. PHPStan clean.

This was one of the two findings I had left alone as "not defects" — on a second look, an endpoint answering 500-with-a-database-message where it has a 400 available is a defect, not a design choice. The other one (the user endpoints having no help class, so a missing parameter says "Wrong parameters" with an empty detail) is next.

…e them

The permissions are the profile — the column holding them is NOT NULL — but the
API read them as optional. A caller who left them out got the database's
integrity error back, a 500 saying nothing about which parameter was missing,
where every other missing parameter on this endpoint answers with a 400 naming
the problem.

Required on create and on edit both. Dropping them from an edit would have
blanked the permissions of a profile that people are already assigned to, which
is worse than the create case: it takes access away from everybody holding it.

The test that recorded the old integrity error now asserts the refusal, and the
edit case gains one of its own.
@blaipr
blaipr merged commit 470893c into main Aug 13, 2026
8 checks passed
@blaipr
blaipr deleted the fix/profile-requires-its-permissions branch August 13, 2026 23:12
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.

1 participant