Page MenuHomePhabricator

Tried to Parse non-JSON in Orchestrator
Closed, InvalidPublicBUG REPORT

Description

Description

Steps to reproduce (step by step instructions, with links, commands and necessary data to reproduce the error)

  1. not clear; this was seen in production logs
  2. https://logstash.wikimedia.org/app/discover#/doc/0fade920-6712-11eb-8327-370b46f9e7a5/ecs-k8s-1-1.11.0-7-2025.05?id=fUyDuZQB60NnMROHZxyM

Observed behavior

  • tried to call .json() on an invalid response
function implementation: Z901 error: FetchError: invalid json response body at http://localhost:6501/w/api.php?action=wikilambda_fetch&format=json&uselang=content&zids=Z13518 reason: Unexpected token 'u', "upstream c"... is not valid JSON

Expected behavior/Acceptance criteria (returned value, expected error, performance expectations, etc.)

  • we should catch this error

Completion checklist

Event Timeline

Unexpected token 'u', "upstream c"... is not valid JSON is also mentioned in T378414 and T371714

Do you know what time this was? I got an error message that said something like that. It happened when I was trying to copy valid JS code from one implementation into a new one. I nearly filed a bug.

Hi @99of9 - I assume you mean the time at which cmassaro observed this error message; if you click on the logstash link that will show you the time. If it's not accessible to you, here's what I see there (UTC): Jan 31, 2025 @ 00:01:36.687

(Interesting that you saw this same error when you were doing something in the UI, besides calling a function.)

Thanks @DMartin-WMF . I don't have privileges for the logstash: "Service access denied due to missing privileges." (or maybe my saved password is old!)

Anyway, that does not match with the time I saw sometime about invalid JSON. I'll try to reproduce that separately. Sorry for the sidetrack!

Another clue for this one: we're calling the evaluator in a bunch of decidedly non-evaluated functions. Here's a more recent example:

https://logstash.wikimedia.org/app/discover#/context/0fade920-6712-11eb-8327-370b46f9e7a5/ewcxMpcBbAObVjXF9Gpw?_g=(filters:!())&_a=(columns:!(orchestrator.namespace,orchestrator.resource.name,message),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!t,index:'0fade920-6712-11eb-8327-370b46f9e7a5',key:orchestrator.namespace,negate:!f,params:(query:wikifunctions),type:phrase),query:(match_phrase:(orchestrator.namespace:wikifunctions))),('$state':(store:appState),meta:(alias:!n,disabled:!t,index:'0fade920-6712-11eb-8327-370b46f9e7a5',key:labels.deployment,negate:!f,params:(query:function-orchestrator),type:phrase),query:(match_phrase:(labels.deployment:function-orchestrator))),('$state':(store:appState),meta:(alias:!n,disabled:!t,index:'0fade920-6712-11eb-8327-370b46f9e7a5',key:normalized.message,negate:!f,params:(query:'function%20implementation:%20z201%20error:%20error:%20function%20evaluation%20failed%20with%20status%20500:%20%7B%22status%22:500,%22type%22:%22internal_error%22,%22title%22:%22payloadtoolargeerror%22,%22detail%22:%22request%20entity%20too%20large%22,%22method%22:%22post%22,%22uri%22:%22%2F1%2Fv1%2Fevaluate%2F%22%7D'),type:phrase),query:(match_phrase:(normalized.message:'function%20implementation:%20z201%20error:%20error:%20function%20evaluation%20failed%20with%20status%20500:%20%7B%22status%22:500,%22type%22:%22internal_error%22,%22title%22:%22payloadtoolargeerror%22,%22detail%22:%22request%20entity%20too%20large%22,%22method%22:%22post%22,%22uri%22:%22%2F1%2Fv1%2Fevaluate%2F%22%7D')))))

The cryptic error is because is because the HTTP fetch resulted in the string "upstream connect error", and our JSON parser throws on that.

We've since addresed this; we now back off when we fail to parse JSON.