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

$c->req->body_data dies internally for JSON request with empty HTTP message body #196

Open
dboehmer opened this issue Oct 24, 2024 · 0 comments

Comments

@dboehmer
Copy link
Contributor

dboehmer commented Oct 24, 2024

I was investigating an issue in our app until I realized there is a bug in Catalyst itself.

How to reproduce:

  • have an app read $c->req->body_data—I tried this with a fresh app created by catalyst.pl by just adding that call to the default action method
  • send invalid JSON like this:
curl -v --json '' http://localhost:3000/

Actual result:

[error] Error Parsing POST 'undef', Error: Can't locate object method "getline" via package "0" (perhaps you forgot to load "0"?) at .../perlbrew/perls/perl-5.38.0-threads-bullseye/lib/site_perl/5.38.0/Catalyst.pm line 4091.

Expected result:

  • either return (); or a catchable exception from parsing the empty string

I think Pull Request #186 solves part of the problem related with repeated calls on $c->req->body_data but with that the code already fails on $fh->seek (see my comment there). Currently the data handler fails for $fh->getline.

Should the data handler always receive a filehandle, possibly an empty one, or does every data handler need to check whether a filehandle is present first?

@dboehmer dboehmer changed the title $c->req->body_data dies internally if run twice with invalid JSON request data $c->req->body_data dies internally for JSON request with empty HTTP message body Oct 24, 2024
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

No branches or pull requests

1 participant