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

Find in files returns error #1315

Closed
trevorfstrong opened this issue Feb 13, 2024 · 24 comments · Fixed by #1318
Closed

Find in files returns error #1315

trevorfstrong opened this issue Feb 13, 2024 · 24 comments · Fixed by #1318
Assignees
Labels
bug Something isn't working

Comments

@trevorfstrong
Copy link

Type: Bug

Opening my workspace connected to local irishealth system I can open server side files no problem, but find in files action fails and displays this error in the Objectscript output window.
intersystems-community.vscode-objectscript version 2.12.2-beta.2 activating with proposed APIs available.

ERROR #16002: Invalid JSON Content
NOTE: api/atelier/ web app is marked for password authentication only.

Extension version: 1.0.3
VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:08:20.941Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz (8 x 1992)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.78GB (3.15GB free)
Process Argv --enable-proposed-api intersystems-community.vscode-objectscript --crash-reporter-id 6908b51a-5f63-40ad-85f8-24f898e529cc
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
vscaat:30438848
c4g48928:30535728
azure-dev_surveyonecf:30548226
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
pydisww1:30959800
b5d27386:30958190
a89i1917:30961429
e3gdj431:30958358
ccp2r3:30958157

@trevorfstrong
Copy link
Author

$ZV = IRIS for Windows (x86-64) 2023.1 (Build 235_1U) Fri Jun 2 2023 13:30:56 EDT

@isc-bsaviano isc-bsaviano transferred this issue from intersystems-community/vscode-objectscript-pack Feb 20, 2024
@isc-bsaviano isc-bsaviano added the bug Something isn't working label Feb 20, 2024
@isc-bsaviano
Copy link
Contributor

Hi @trevorfstrong, I see that you created a WRC ticket for this issue, and that the error message there is different than the one you posed here. Which error message is correct ERROR #16002: Invalid JSON Content or Non-JSON response to ...?

@isc-bsaviano isc-bsaviano removed the bug Something isn't working label Feb 20, 2024
@trevorfstrong
Copy link
Author

It appears to be the invalid json content when attempting to get "find in files" to trigger.

@isc-bsaviano
Copy link
Contributor

Thanks for clarifying. Can you use Wireshark or the web gateway's HTTP trace feature to capture the REST request and response that get sent when you try to search through files? The request will be a POST to the /api/atelier/v6//work endpoint. The response will have a 400 Bad Request header. Seeing the body of the request and response will help me diagnose the cause of the issue.

@trevorfstrong
Copy link
Author

Is this what you need?
image

@trevorfstrong
Copy link
Author

CSP.zip

@isc-bsaviano
Copy link
Contributor

@trevorfstrong Unfortunately, that doesn't have the oe piece of data that I need. What I need is the body of the request that prompts the 16002 error. I need to check if it's valid JSON. If it is, then there may be a bug on the server. If it's not, then there's a bug in this extension because it should always send JSON.

@trevorfstrong
Copy link
Author

Very odd.
I have traced the api call, and edited the server side method.
My terminal testing seems true, however the isfs call fails with the error as seen in my debug trap

OMNI:DLS>zw ^%TREV(13)
^%TREV(13)="{""request"":""search"",""console"":false,""query"":""hang 5"",""regex"":false,""project"":""2235-Waters-NBS Standalone"",""word"":false,""case"":false,""wild"":false,""documents"":"".cls,.inc,.mac,.int"",""system"":false,""generated"":false,""mapped"":true,""max"":20000}"

OMNI:DLS>s tRequest={}.%FromJSON(^%TREV(13))
OMNI:DLS>i tRequest.request="search" && ((tRequest.%GetTypeOf("query")'="string") || ((tRequest.%IsDefined("documents")) && (tRequest.%IsDefined("project"))) ||(('tRequest.%IsDefined("documents")) && ('tRequest.%IsDefined("project"))) ||((tRequest.%GetTypeOf("system")'="unassigned") && (tRequest.%GetTypeOf("system")'="boolean")) ||((tRequest.%GetTypeOf("generated")'="unassigned") && (tRequest.%GetTypeOf("generated")'="boolean")) ||((tRequest.%GetTypeOf("regex")'="unassigned") && (tRequest.%GetTypeOf("regex")'="boolean")) ||((tRequest.%GetTypeOf("max")'="unassigned") && (tRequest.%GetTypeOf("max")'="number")) ||((tRequest.%GetTypeOf("word")'="unassigned") && (tRequest.%GetTypeOf("word")'="boolean")) ||((tRequest.%GetTypeOf("case")'="unassigned") && (tRequest.%GetTypeOf("case")'="boolean")) ||((tRequest.%GetTypeOf("wild")'="unassigned") && (tRequest.%GetTypeOf("wild")'="boolean")) ||((tRequest.%GetTypeOf("mapped")'="unassigned") && (tRequest.%GetTypeOf("mapped")'="boolean")) ||((tRequest.%GetTypeOf("include")'="unassigned") && (tRequest.%GetTypeOf("include")'="string")) ||((tRequest.%GetTypeOf("exclude")'="unassigned") && (tRequest.%GetTypeOf("exclude")'="string")) ||((tRequest.%GetTypeOf("console")'="unassigned") && (tRequest.%GetTypeOf("console")'="boolean"))) w "yes"
yes
OMNI:DLS>zw ^%TREV(14) ^%TREV(14)=$lb("8@%Library.DynamicObject","0 "_$lb($lb(16002,,,,,,,,,$lb(,"APL",$lb("e^QueueAsync+66^%Api.Atelier.v6.1^1","e^DispatchRequest+34^%CSP.REST.1^1","e^DispatchRequest+48^%CSP.REST.1^1","e^zPage+25^%CSP.REST.1^1","e^zPage+2^%Atelier.REST.1^1","e^CSPDispatch+495^%SYS.cspServer^2","d^CSPDispatch+274^%SYS.cspServer^1","d^ProcessRequest+1^%CSP.Session.1^1","d^Request+683^%SYS.cspServer2^1","d^Request+25^%SYS.cspServer2^1","d^ProcessRequest+1^%CSP.Request.1^1","d^css+21^%SYS.cspServer2^1","d^SuperServer+60^%SYS.SERVER^2","d^^^0"))))/* ERROR #16002: Invalid JSON Content */)

OMNI:DLS>w tRequest.%ToJSON()
{"request":"search","console":false,"query":"hang 5","regex":false,"project":"2235-Waters-NBS Standalone","word":false,"case":false,"wild":false,"documents":".cls,.inc,.mac,.int","system":false,"generated":false,"mapped":true,"max":20000}

@trevorfstrong
Copy link
Author

Here are the mods to atelier class at point of error...
} ElseIf tRequest.request="search" && (
(tRequest.%GetTypeOf("query")'="string") ||
((tRequest.%IsDefined("documents")) && (tRequest.%IsDefined("project"))) ||
(('tRequest.%IsDefined("documents")) && ('tRequest.%IsDefined("project"))) ||
((tRequest.%GetTypeOf("system")'="unassigned") && (tRequest.%GetTypeOf("system")'="boolean")) ||
((tRequest.%GetTypeOf("generated")'="unassigned") && (tRequest.%GetTypeOf("generated")'="boolean")) ||
((tRequest.%GetTypeOf("regex")'="unassigned") && (tRequest.%GetTypeOf("regex")'="boolean")) ||
((tRequest.%GetTypeOf("max")'="unassigned") && (tRequest.%GetTypeOf("max")'="number")) ||
((tRequest.%GetTypeOf("word")'="unassigned") && (tRequest.%GetTypeOf("word")'="boolean")) ||
((tRequest.%GetTypeOf("case")'="unassigned") && (tRequest.%GetTypeOf("case")'="boolean")) ||
((tRequest.%GetTypeOf("wild")'="unassigned") && (tRequest.%GetTypeOf("wild")'="boolean")) ||
((tRequest.%GetTypeOf("mapped")'="unassigned") && (tRequest.%GetTypeOf("mapped")'="boolean")) ||
((tRequest.%GetTypeOf("include")'="unassigned") && (tRequest.%GetTypeOf("include")'="string")) ||
((tRequest.%GetTypeOf("exclude")'="unassigned") && (tRequest.%GetTypeOf("exclude")'="string")) ||
((tRequest.%GetTypeOf("console")'="unassigned") && (tRequest.%GetTypeOf("console")'="boolean"))
) {
s ^%TREV($I(^%TREV))=tRequest.%ToJSON()

        Set tSC = $$$ERROR($$$InvalidJSONContent)
    	s ^%TREV($I(^%TREV))=$lb(tRequest,tSC)
        Set %response.Status = ..#HTTP400BADREQUEST
        Quit
    }

@isc-bsaviano
Copy link
Contributor

@trevorfstrong Thanks, that's really helpful. I've identified what the problem is. The client is sending a value for both "project" and "documents". That should never happen. Can you send me the contents of the .code-workspace file that you're using?

@trevorfstrong
Copy link
Author

Is this what you want?
Not sure if this helps or is a separte topic but, we work heavily with projects and would want the project info for the currently opened file sent to SourceControl serverside hooks too. If this doesn't happen, we will have to identify the current project in a different manner.
{
"folders": [
{
"name": "2235-Waters-NBS Standalone - omnilocal:APL",
"uri": "isfs://omnilocal:apl/?project=2235-Waters-NBS Standalone"
}
],
"settings": {
"objectscript.conn": {
"active": false
}
}
}

@isc-bsaviano isc-bsaviano added the bug Something isn't working label Feb 21, 2024
@isc-bsaviano isc-bsaviano self-assigned this Feb 21, 2024
@isc-bsaviano
Copy link
Contributor

isc-bsaviano commented Feb 21, 2024

@trevorfstrong Yes, that's what I was looking for! That looks fine to me, so I'm not sure why the extension is sending both "project" and "documents". I will dig into the code when I have time. I think your project source control request is covered by #1312 and #1313.

@isc-bsaviano
Copy link
Contributor

Hi @trevorfstrong, I've opened PR #1318 which should fix your issue. If you want to try my fix you can download and install the vsix found here.

@trevorfstrong
Copy link
Author

Thanks. that works.
The CTRL+SHIFT+F only seems to search on the local files previously accessed.
I can't seem to get it to search all files on the server side and how to restrict the search to a specific server/namespace escapes me. Any thoughts or advice?

@gjsjohnmurray
Copy link
Contributor

Have you followed me steps in the README to enable proposed APIs?

@trevorfstrong
Copy link
Author

Yep. I see this in the output too.
intersystems-community.vscode-objectscript version 2.12.2-dev.1318 activating with proposed APIs available.

@trevorfstrong
Copy link
Author

Maybe this will help.
CSP.zip

@trevorfstrong
Copy link
Author

Doesn't look like it passed the search param thru at all now.
image

@isc-bsaviano
Copy link
Contributor

@trevorfstrong I see requests to the /work endpoints so unless you compiled a file at the same time, those requests are searches. The request bodies are still not in that log so I couldn't tell what exactly it was trying to search for. Based on the image, I think you mean to turn off the regex option (the .* icon). That uses a JavaScript (or $MATCH) style regex. I'm not sure what type of pattern matching you're trying to do with the * character. I use regexr.com to validate my regexes.

@trevorfstrong
Copy link
Author

Hi Brett. It doesn't matter what i type in or what regex expression i use, nothing shows up in the CSP.log for the work request with that search string.
Did you break something or am i missing a config step here after installing, reloading and restarting VSC with your new extension?
The doco says I don't need to do anything if already done with previous beta extension but maybe i have misread the instructions. Something seems to be blocking the sending of serverside payload despite this showing in the output. Has it not activated?
intersystems-community.vscode-objectscript version 2.12.2-dev.1318 activating with proposed APIs available.

@trevorfstrong
Copy link
Author

image

@trevorfstrong
Copy link
Author

image

@isc-bsaviano
Copy link
Contributor

isc-bsaviano commented Feb 23, 2024

Thanks for the screenshots. That vsix definitely works; I'm using it right now in my own workspace. If you see that message then proposed APIs are enabled, so that's not the issue. I'm going to download a community edition container with the same $ZV as your server just to be sure that there's nothing wrong with that version, but I doubt that there is.

EDIT: I was able to search against a project using the same server version as you.

@trevorfstrong
Copy link
Author

Fixed by deleting the current settings, workspace settings and reconnecting to server/namespace using a virtual folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants