-
Notifications
You must be signed in to change notification settings - Fork 20
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
bug: stack traceback
error on some tests in the writefile
function
#229
Comments
I have tried the following (without success):
function convert_blob_to_string(value)
if type(value) == "number" or type(value) == "string" then
return value
else
return tostring(value)
end
end
I have also printed the
Here what I printed before the logger.debug({ "cmd output dbg test type:", type(cmd_output) })
logger.debug({ "cmd output dbg test:", cmd_output })
logger.debug({ "cmd output path dbg test type:", type(cmd_output_path) })
logger.debug({ "cmd output path dbg test:", cmd_output_path }) Here the outcome:
|
Something that actually 'kinda worked' was using the following: function convert_blob_to_string(value)
if type(value) == "number" or type(value) == "string" then
return value
else
return table_to_string(value)
end
end
function table_to_string(t)
local result = ""
local function encode_value(v)
if type(v) == "number" then
return tostring(v)
elseif type(v) == "string" then
return '"' .. v .. '"'
elseif type(v) == "boolean" then
return v and "true" or "false"
elseif type(v) == "table" then
return table_to_string(v)
else
return "nil"
end
end
local function encode_table(t)
local result = "{"
local first = true
for k, v in pairs(t) do
if not first then
result = result .. ","
end
first = false
result = result .. tostring(k) .. ":" .. encode_value(v)
end
result = result .. "}"
return result
end
return encode_table(t)
end and then:
The output is OFC horrible: |
Hey @rbroggi and thanks for this report. I haven't had time to dig into this one yet. In the meantime, if you set the runner to |
I just made a low-effort search and kind of seems the "Using default configuration for the set" is related to MongoDB: https://github.com/search?q=%22Using+a+default+configuration+for+the+set%22&type=code Is that detail potentially significant here? |
I use testcontainers and indeed mongo is part of the containers. I tried to make a small reproducer with only mongo container but failed. |
Will try that later. Thx for the tip |
Sounds good. Based on the outcome of using |
Unfortunately no change here |
I've spent a good amount of time trying to debug this and I think the bottom line is that somehow, I'm getting binary data being written to the test output. I couldn't find an easy way of reproducing it though which is making me a bit mad on why this is the case in my actual problem. I need to switch focus from that right now but will come back to it later. |
No worries, no stress. I just don't think I can aid much here until we can reproduce it. I'm also not very keen on modifying the current code without understanding why. Ideally we'd be able to write a test for this case and assert the code is handling it correctly. |
Ok, managed to create a reproducer: It is not completely deterministic as it seems that not all bytes will screw the output sufficiently. This reproducer breaks the test most of the times though... It has nothing to do with mongo but with binary output. Some binary outputs simply screw the parser. |
That's excellent @rbroggi that you managed to set something reproducible up. I'll have a look, but I can't promise exactly when. |
Had an inspiration this night and was convinced (and partially still am) that a utf-8 sanitization should do the trick. I tried some AI generated lua function since I have basically no experience in the language. Unfortunately no success. Maybe you can more successfully implement such sanitizer |
@rbroggi sorry for the delay. I just checked out your PR branch to have a look. When I have {"Time":"2025-01-02T23:56:52.442264+01:00","Action":"start","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test"}
{"Time":"2025-01-02T23:56:52.65704+01:00","Action":"run","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test"}
{"Time":"2025-01-02T23:56:52.65715+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test","Output":"=== RUN Test\n"}
{"Time":"2025-01-02T23:56:52.657177+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test","Output":"Ve\ufffd\ufffd\ufffd\ufffdZK\ufffd\ufffd\ufffd_\ufffd\ufffd\ufffd\ufffd\ufffde\u001c9\ufffd\ufffdH\ufffd\ufffd\ufffd\u001e \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd}h\ufffdv\n"}
{"Time":"2025-01-02T23:56:52.657203+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test","Output":"\ufffd_\u0002k\ufffd\ufffdHd\ufffd\ufffd\ufffdΨ\ufffd\ufffd\ufffdU1\ufffd\ufffd'\ufffd\ufffd2\u001at\ufffdb\ufffdq\ufffd\ f\ufffdb\ufffd\ufffdN\u0018}\ufffd.\ufffd\ufffd\ufffd0\ufffd\ufffdty\ufffd\ufffdN\ufffdd\ufffdJ\ufffd\ufffd\ufffdMAҞ\u000b\ufffd\ufffdHZ\ufffd9\ufffd\u0004\ufffd2\ufffd\u001dP2e\ufffd\ufffd͈\ufffd\ufffd\ufffd\ufffdR@\ufffd\u001d"}
{"Time":"2025-01-02T23:56:52.65738+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test","Output":"\ufffdeW\ufffd\ufffd\ufffd\ufffd\ufffd@\ufffd\ufffd\ufffd\u000e\ufffd\u001a$H@\u0007\ufffd6\b\ufffdV\u0014\ufffd\ufffd\ufff d\r\ufffd8X\u0013պ/\ufffdnِ\ufffd\u000e\ufffd\ufffdܪ\ufffd\ufffd\ufffd\u0026\ufffd\ufffd/ \u0012\u000b\ufffd\u000f\ufffd\ufffd\ufffdIOz\ufffd\ufffdH\ufffdmR9/\ufffd\u0002e\ufffd\ufffd\r\ufffd\b\ufffd\ufffdi\ufffd6~a\ufffdV\ufffd\ufffd\rH\ufffdj9\u0013\ufffd\ufffd\ufffd\ufffd\ufffd\u001e\ufffd\u0013 \ufffd4l\ufffd0\ufffd=\ufffd\ufffd#vS\ufffdy\ufffd0_0RO\u001d\ufffdh\u0013\ufffdrR\ufffd\ufffd2\ufffd0\ufffdV \ufffdDZ\n"}
{"Time":"2025-01-02T23:56:52.657412+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/test","Test":"Test","Output":"\ufffdHd\ufffd8\ufffd\ufffd^j\ufffd\ufffdpJ\ufffd\ufffd`\"\u001a.\u0001y\ufffd\u000f\ufffd\ufffd\ufffd\ufffd"}
{"Time":"2025-01-02T23:56:52.657429+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Test":"Test","Output":"xs\ufffd\\.\ufffd\ufffd\u001dz\ufffd\ufffdM\ufffd\r\ufffd\ufffd\ ufffd\ufffd.qSY\ufffdoJ\ufffdэ\u0011ӡ\ufffd\ufffd\ufffd^\ufffd\ufffd\u0010@K\ufffd.\ufffd\ufffd\u0012\ufffd\ufffd}\u003e \ufffd,\u0007\ufffd\ufffd\ufffdd\ufffd\ufffd]_w\ufffdb\u000e\t\ufffd\u0015qU\u001c\ufffdK\u001c2\u0002\ufffd"}
{"Time":"2025-01-02T23:56:52.657499+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Test":"Test","Output":"\ufffdG\ufffd\ufffd$g\ufffd\u0005]\ufffdrjykb\ufffd\u0017(̶X\ufff dv\ufffd\ufffd^\ufffd\ufffd]mM.N\u0015W\ufffdr\ufffd\ufffd\ufffd\u0018bn\ufffd\u0006`\ufffd\ufffd\ufffdH\u0010\ufffd\u00 0e\ufffd\ufffd-\ufffd\u0011\ufffd\ufffd\ufffd0\u000fE\ufffd\ufffdry\ufffd$E\ufffd7\ufffdp\u0026-xK`\ufffd\ufffd\u0013p\u fffd\u0005Sn$\ufffd\ufffdL\u0004!\ufffd\ufffd7~\ufffd[\ufffdL\u0018\u001d\ufffd4\ufffd\u00018\u0014\ufffd\ufffd~\ufffd\u fffd\ufffd\ufffdg\ufffd\ufffd^\ufffd\ufffd\ufffdL\bﴟ\ufffd\ufffdN\ufffd\ufffd%\u0026\ufffd3Wzi\u000b\ufffdZ\f\ufffdf\uff fd\ufffd\f/!\ufffd\ufffd\ufffd\ufffd {\u0000J1\ufffdk\u0004\ufffdC\ufffd\u000bmޘ\ufffd:\ufffd\ufffd\fz\ufffd\ufffd\u0010 ӺxE\u0001{\ufffd{@F/\u0018cN}\ufffd\ufffd\u001cF@\ufffdPY\u001eE0\ufffd\u001a[\ufffdč\u001f\t\ufffd\ufffd\ufffd\ufffd\u0 004\ufffd\ufffd\ufffd\u0010\ufffd\ufffdw\ufffd\ufffd\ufffd\ufffd2\ufffd^\ufffd,o\ufffd\ufffd\ufffd00\u0001!\ufffdT\ufffd \ufffd\ufffdp\ufffd\u003cwEcSLA\u0004\ufffdT\ufffdY]\ufffd\ufffd/eK3\"\ufffdB\ufffd\u0014\"\ufffd\ufffdz\ufffd\ufffd#\uf ffdz\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd'\u000e\ufffd\ufffd\ufffdhe\ufffd\ufffd~\u0005\ufffd\\\ufffd\t\ufff d\ufffd\ufffd\ufffdq\ufffd\ufffdV\ufffd\u0018ڂ\ufffd\ufffd\u0017\ufffdA3\ufffd/\ufffd\u0004\ufffd\u001c\ufffd\u0015\ufff do\ufffdZ+\ufffd\f\ufffd\ufffdM\ufffd\ufffd`\ufffd\ufffdr\ufffdh*z\ufffd\u0017G\ufffd\ufffd\u001c\ufffd\u001b\ufffdQ\uff fd\ufffd\ufffd\ufffd\ufffd2\"\u0010\ufffd?\u000e\ufffd6ڻ \ufffd\u001a\ufffd"}
{"Time":"2025-01-02T23:56:52.657602+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Test":"Test","Output":"\ufffd\ufffd\u0015\u003c_\u000bDZry\ufffd.\u0012\u0015\ufffdP$[\u fffd$\ufffdg\ufffd"}
{"Time":"2025-01-02T23:56:52.657621+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Test":"Test","Output":"\ufffd\u00053Fnl\ufffdb\u001d%hэ\u003er\ufffd\ufffd\u0006\ufffd\ ufffd\ufffd\u0002-5\ufffd\u000e \ufffdڛD\ufffd\ufffdGA\ufffd\ufffd.3\ufffd\ufffde\ufffd\ufffdQ]\ufffd5\u000bd\ufffd\ufff d\ufffd\ufffd\ufffd9\ufffd\ufffd\u0005\ufffd\u0019\ufffd\ufffd\ufffd\ufffd0\ufffd=+7\f\ufffdG\f\u001c\ufffd\u0004\u00266 \ufffd\ufffd\ufffd\ufffd\u0003}M9\ufffd\ufffd\ufffd\ufffdR\ufffdW\u001dN\ufffdy\ufffd\ufffd\ufffdP\ufffd^\ufffd\ufffd{Ng \ufffd\u001aà\ufffd\ufffdQ\tP\ufffd9\ufffdz\ufffd\ufffd\ufffd\ufffd:\ufffd\u0002\ufffd\ufffd@\ufffdv\u0014\ufffd!ys\u000 7\ufffdW\ufffd#{[Hl\u0011\u0004'\ufffdz\ufffd\ufffdn\u0014\ufffd \ufffd\ufffdG0n\n"}
{"Time":"2025-01-02T23:56:52.657759+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Test":"Test","Output":"\ufffd\ufffd\ufffd\ufffda\ufffd vPF-\ufffdM\ufffd#\ufffd\ufffd\u fffd\ufffd\ufffd\u0019:\u0005\ufffd\ufffdx\ufffdLC\ufffd\ufffd B\ufffd0\ufffdsf\u0002Ax\ufffd--- PASS: Test (0.00s)\n"}
{"Time":"2025-01-02T23:56:52.657771+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Output":"PASS\n"}
{"Time":"2025-01-02T23:56:53.661516+01:00","Action":"output","Package":"github.com/fredrikaverpil/go-playground/bugs/neo test-golang/internal/core/test","Output":"ok \tgithub.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/cor e/test\t1.219s\n"}
{"Time":"2025-01-02T23:56:53.661596+01:00","Action":"pass","Package":"github.com/fredrikaverpil/go-playground/bugs/neote st-golang/internal/core/test","Elapsed":1.22} Switching over to the
I guess it's the This test encodes the bytes so that the test doesn't fail: func TestEncoded(t *testing.T) {
b := make([]byte, 1000)
_, err := rand.Read(b)
require.NoError(t, err)
t.Logf("Random bytes (hex): %x", b)
} Is this really representative of the issue you saw with the testcontainer? Not even $ go test -v ./...
? github.com/fredrikaverpil/go-playground/bugs/neotest-golang [no test files]
=== RUN TestSomething
--- PASS: TestSomething (0.00s)
PASS
ok github.com/fredrikaverpil/go-playground/bugs/neotest-golang/internal/core/dto (cached) |
Hey, @fredrikaverpil, Yep I'm quite confident this is exactly the issue and it is the same error that I faced while using testcontainer (even though it's not a testcontainers fault but the result of a binary log of one of the containers). I'm quite confident that the issue is indeed a non - UTF-8 valid byte sequence, this is why I setup the reproducer like this. The test should not fail IMO due to that. Do you agree? |
Whoops, I need to correct myself here; I forgot the build tag, and with that added
Yes, it's possible that neotest-golang should perform sanitization. However, I'm still skeptical towards whether your test example is representative of what is going on in the mongodb testcontainers example. Anyhow, I tried to do something about this in the { "fredrikaverpil/neotest-golang", branch = "sanitization" } But I'm unfortunately unable to completely eliminate all garbage that gets added by
Maybe have a look at the implementation... and see if you can spot what I'm doing wrong. |
@rbroggi I've merged the implementation. Please open up a new issue if the issue persist. |
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.2
Operating system/version
arch
Output from
:checkhealth neotest-golang
Describe the bug
For some of my tests the
writefile
method fails as briefly discussed in this other issue.Those tests are frequently
integration
tests but I'm not sure this is the discriminant for the behavior.I have collected a debug with the content that breaks the method since I'm unable to reproduce this issue on a reproducer:
I've placed the
logger.debug({ "cmd output dbg test:", cmd_output })
right before theasync.fn.writefile(cmd_output, cmd_output_path)
call and here is what I got:Sometimes seems that the
cmd_output
is not a String nor a Number. How can we correct that?Steps To Reproduce
I am unable to find the discriminant of the type of test that actually generate a Blob output.
Expected Behavior
Either we should coalesce the Blob to a string or make the
writefile
method accept a BlobYour Lua setup
No response
The text was updated successfully, but these errors were encountered: