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

Ray does not dump binary strings #931

Open
sebj54 opened this issue Aug 27, 2024 · 5 comments
Open

Ray does not dump binary strings #931

sebj54 opened this issue Aug 27, 2024 · 5 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@sebj54
Copy link

sebj54 commented Aug 27, 2024

Describe the bug

When you attempt to dump a binary string or anything containing one (like an array or an object), Ray does not dump anything. It just fails silently.

Versions

Ray version (you can see this in "About Ray"): 2.8.1

You can use composer show to get the version numbers of:

  • spatie/ray package version: 1.41.2
  • spatie/laravel-ray package version (if applicable): 1.37.1

PHP version: 8.2.17
Laravel version (if applicable): 11.18.1

To Reproduce

Add this in your code:

ray(hex2bin('ae0f3d'));

Expected behavior

Ray should display this (like the console when dump is used):

b"®\x0F="

Desktop (please complete the following information):

  • OS: MacOs
  • Version: 14.6.1
@timvandijck
Copy link
Member

@sebj54 a bit late to the party but I was just investigating this.

I am not too familiar with the subject so maybe I'm just confused.

Using the example Ray indeed silently "fails".
But if I run ray(json_encode(hex2bin('ae0f3d'))) it shows false in Ray. Which is a possible response from the hex2bin method: https://www.php.net/manual/en/function.hex2bin.php

If I use the example from the PHP docs:

ray(hex2bin("6578616d706c65206865782064617461"));

I do get the proper response in Ray:

Image

So I am not sure what kind of magic the dump method does to get a different result.

@timvandijck timvandijck added the help wanted Extra attention is needed label Dec 2, 2024
@sebj54
Copy link
Author

sebj54 commented Dec 2, 2024

But if I run ray(json_encode(hex2bin('ae0f3d'))) it shows false in Ray. Which is a possible response from the hex2bin method: https://www.php.net/manual/en/function.hex2bin.php

Actually, I think json_encode is returning false here, not hex2bin.

Image

I don't know how Ray works under the hood but maybe the whole problem is due to JSON encoding. Binary strings are not supported in JSON objects:

Image

@timvandijck
Copy link
Member

@sebj54 I think you are on to something with this. All data is send encoded as json over HTTP to the Ray app that runs a small node server to receive the data.

@sebj54
Copy link
Author

sebj54 commented Dec 2, 2024

Then I really don't know how you can deal with that issue then.

Maybe the least you could do is to show an error or a warning in Ray, like "the object you tried to dump could not be JSON encoded. It can save a lot of time to Ray users wondering why there is no output in Ray while they are debugging 😅

@D-nov
Copy link

D-nov commented Jan 14, 2025

Popping in to "bump" this because I got the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants
@sebastienhenau @timvandijck @sebj54 @D-nov and others