-
Notifications
You must be signed in to change notification settings - Fork 58
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
fix: Handle when required resource
parameter is missing or empty
#1951
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Josh <[email protected]>
Social Run #985
Run Properties:
|
Project |
Social
|
Branch Review |
fix-missing-resource-issue-1888
|
Run status |
Errored #985
|
Run duration | 01m 07s |
Commit |
4c35775a1f: fix: Handle when required `resource` parameter is missing or empty
|
Committer | Josh |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
2
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
0
|
View all changes introduced in this branch ↗︎ |
Signed-off-by: Josh <[email protected]>
This did not help for me, the error I now get is:
|
Signed-off-by: Josh <[email protected]>
@paulvt Oops. Try now. :) |
Unfortunately still the same. And I see the static-psalm-analysis GitHub Action says that strings cannot be |
Though I don't see how it should ever end up truly null. It should be |
Same for me. |
Co-authored-by: Côme Chilliet <[email protected]> Signed-off-by: Josh <[email protected]>
Signed-off-by: Josh <[email protected]>
$requestUri = $request->getRequestUri(); | ||
if ($requestUri !== '') { | ||
parse_str(parse_url($requestUri, PHP_URL_QUERY) ?? '', $query); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$requestUri = $request->getRequestUri(); | |
if ($requestUri !== '') { | |
parse_str(parse_url($requestUri, PHP_URL_QUERY) ?? '', $query); | |
} | |
parse_str(parse_url($request->getRequestUri(), PHP_URL_QUERY) ?? '', $query); |
The if is not useful anymore, I think
Exception parse_str(): Argument #1 ($string) must be of type string, null given in file '/opt/nextcloud/apps/social/lib/WellKnown/WebfingerHandler.php' line [...]
#1888Summary
resource
is a required parameter. Avoid a 500 error when it's missing or empty. Instead generate a proper 400 bad request response.Refs:
P.S. Semi-related: Our default setup checks in
server
aren't compatible withsocial
being enabled since they only check for 200 or 404 (neither of which are applicable whensocial
is enabled and when querying/.well-known/webfinger
without any parameterst):https://github.com/nextcloud/server/blob/16812837157395c078a9689cd51530a6382e17d2/apps/settings/lib/SetupChecks/WellKnownUrls.php#L48
This PR doesn't impact those either way directly (since the prior 500 nor the 400 added via this PR would have ever passed). I'll try to take a closer look at those over in
server
. EDIT: nextcloud/server#49440