Skip to content

Comments

Fix controller_rest's issue with page paths#756

Merged
loetie merged 1 commit intomasterfrom
OEI2-369
Feb 9, 2026
Merged

Fix controller_rest's issue with page paths#756
loetie merged 1 commit intomasterfrom
OEI2-369

Conversation

@pasqu4le
Copy link
Contributor

@pasqu4le pasqu4le commented Feb 9, 2026

The current controller_rest_resources:path_to_id expects the page path to contain an integer and fails catastrophically otherwise.

I triggered this accidentally while testing for another issue by using a path with text (e.g. /page/not_existing) which controller_page can handle just fine, but controller_rest_resources crashes on.

This fixes the function to accept paths that might contain a resource’s unique name (as controller_page does) and by not crashing on incorrect inputs (it returns an error tuple instead).

@pasqu4le pasqu4le requested a review from loetie February 9, 2026 11:38
@pasqu4le pasqu4le self-assigned this Feb 9, 2026
["page", Id | _] ->
{ok, erlang:list_to_integer(Id)};
case m_rsc:rid(Id, Context) of
undefined -> {error, enoent};
Copy link
Contributor

Choose a reason for hiding this comment

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

@pasqu4le should this be treated as a page path then if it is not page/id? so it still checks m_rsc:page_path_to_id, like in the else of the case above this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should this be treated as a page path then if it is not page/id?

Good question, but I don't think so. If the path starts with "page" then it's handled by the page dispatch/controller and it should have an identifier (id or otherwise).

If it's not, I don't think we should treat it as another path.

@loetie loetie merged commit 4303428 into master Feb 9, 2026
1 check passed
@loetie loetie deleted the OEI2-369 branch February 9, 2026 15:00
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