Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-13886: Don't crash on wrong link_type for paged rels #3434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

reosarevok
Copy link
Member

Fix MBS-13886

Problem

Trying to access a paged relationships list with a non-existing link type, such as /work/8dcffe3f-cb5c-3459-b6d7-0558a2174808?direction=2&link_type_id=277&page=1, causes a JS TypeError. Found in Sentry.

Solution

I assume someone was just playing around with the URL params and I cannot think of any other way of getting here than the user fiddling like that. As such, it seems to make sense to block this at the controller level and a 400 BAD REQUEST seems like a good fit.

Testing

Manually, on the URL above.

@reosarevok reosarevok added the Bug Bugs that should be checked/fixed soonish label Jan 3, 2025
my $link_type = $c->model('LinkType')->get_by_id($link_type_id);
unless ($link_type) {
$c->stash(
message => l('The provided relationship type does not exist'),
Copy link
Member

Choose a reason for hiding this comment

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

We have the following string in root/components/RelationshipsTable.js which makes it sound like this case should be handled already: The provided relationship type ID is not valid.. Erroring seems fine, but perhaps we can use the existing string and remove that unused fallback.

Copy link
Member Author

@reosarevok reosarevok Jan 7, 2025

Choose a reason for hiding this comment

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

Oh yeah, I guess that fallback doesn't actually work because the linkPhrase calculation crashes before we can check this. Wonder if it originally worked? I actually even tried to find an existing string to reuse and failed, sigh. Thanks!

This was hit and logged on Sentry (leads to a TypeError on JS).
I assume someone was just playing around with the URL params, but
it seems to make sense to block this at the controller level and since
I cannot think of any other way of getting here than the user fiddling
400 seems like a good fit.

We were trying to do this at the JS level earlier, but it crashes
when trying to calculate the linkPhrase we were hoping to check
(possibly a new issue after some changes, or possibly it never
worked) so it never gets to return the error. It seems sensible
in any case to check on the Perl layer and just not bother
with any of the loading if there's a clear broken situation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bugs that should be checked/fixed soonish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants