croservices / cro

Development tools for building services and distributed systems in Raku using the Cro libraries.
https://cro.services/
Artistic License 2.0
88 stars 35 forks source link

Don't know how to jsonify Capture #130

Closed christophhalbi closed 3 years ago

christophhalbi commented 3 years ago

Hello,

zef info Cro
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
- Info for: Cro
- Identity: Cro::Core:ver<0.8.4>
- Recommended By: Zef::Repository::Ecosystems<cpan>
- Installed: Yes, as Cro::Core:ver<0.8.3>
Description:     Implements the asynchronous pipeline at the heart of all Cro libraries.
License:         Artistic-2.0
Source-url:      http://www.cpan.org/authors/id/J/JN/JNTHN/Perl6/cro-core-0.8.4.tar.gz

I have a Cro Application with an endpoint looking like this:

post -> Int $homepage_id!, 'add-homepage-change' {
            request-body -> (:$employee_id) {

                my %homepage_change = $.model.add-homepage-change(
                    :$homepage_id,
                    :$employee_id,
                );
                content 'application/json', %homepage_change;
            }
        }

When I request the endpoint, I get something like this randomly:

Don't know how to jsonify Capture
  in block  at /usr/share/perl6/vendor/sources/0F7FB2F694A23799D9133B98761A195FBCD8C2CC (JSON::Fast) line 309
  in sub jsonify at /usr/share/perl6/vendor/sources/0F7FB2F694A23799D9133B98761A195FBCD8C2CC (JSON::Fast) line 230
  in sub unpretty-associative at /usr/share/perl6/vendor/sources/0F7FB2F694A23799D9133B98761A195FBCD8C2CC (JSON::Fast) line 221
  in sub jsonify at /usr/share/perl6/vendor/sources/0F7FB2F694A23799D9133B98761A195FBCD8C2CC (JSON::Fast) line 291
  in sub to-json at /usr/share/perl6/vendor/sources/0F7FB2F694A23799D9133B98761A195FBCD8C2CC (JSON::Fast) line 319
  in method serialize at /usr/share/perl6/vendor/sources/51D910F9C1308357EE70E7A040781FCDCF99DDFE (Cro::HTTP::BodySerializers) line 82
  in method body-byte-stream at /usr/share/perl6/vendor/sources/AB199B92DD9F8AA3DB18FF944B7E1FDF6D7C043B (Cro::MessageWithBody) line 29
  in block  at /usr/share/perl6/vendor/sources/0F69C0C9BD82F11FAF77CE6AE1F9E881CA309571 (Cro::HTTP::ResponseSerializer) line 37
  in block  at /usr/share/perl6/vendor/sources/6D2B9EAD4DC4FCDFF835D33B0CA4F37530A7DDCE (Cro::HTTP::Log::File) line 33
  in block  at /usr/share/perl6/vendor/sources/9963EC1A4D584766640A77FE4C36A9631567F9B4 (Cro::HTTP::Internal) line 45
  in block  at /usr/share/perl6/vendor/sources/7E3F216F834F3015FB006B1C378858BD35B49B37 (Cro::HTTP::Router) line 232
christophhalbi commented 3 years ago

Not related to cro at all. Was a problem we my JSON (contained a '\' from time to time).