Trey
Trey3w ago

Unable to access results value

I am encountering an error when accessing the properties of a scripts results. As you can see on the right side under results, the snow_ticket.error does in fact exist. Yet I'm getting the following error:
${results.snow_ticket?.error}``: TypeError: Cannot read properties of null (reading 'error')
${results.snow_ticket?.error}``: TypeError: Cannot read properties of null (reading 'error')
No description
18 Replies
rubenf
rubenf3w ago
try results?.snow_ticket?.error
Trey
TreyOP3w ago
tried that too. same result I even tried ${results.snow_ticket?.error || 'N/A'}
rubenf
rubenf3w ago
can you send me your full expression please
Trey
TreyOP2w ago
Failed to create ServiceNow ticket!\n\n${results.snow_ticket?.error}
Failed to create ServiceNow ticket!\n\n${results.snow_ticket?.error}
Hey @rubenf, were you able to look in to this? thanks
rubenf
rubenf2w ago
I wasn't able to reproduce:
summary: ""
value:
modules:
- id: snow_ticket
value:
type: rawscript
content: |
// import * as wmill from "windmill-client"

export async function main(x: string) {
return {error: "foo"}
}
language: bun
input_transforms:
x:
type: static
value: ""
assets: []
- id: a
value:
type: rawscript
content: |
// import * as wmill from "windmill-client"

export async function main(x: string) {
return x
}
language: bun
input_transforms:
x:
type: javascript
expr: >-
`Failed to create ServiceNow
ticket!\n\n${results.snow_ticket?.error}

`
assets: []
schema:
$schema: https://json-schema.org/draft/2020-12/schema
properties: {}
required: []
type: object
summary: ""
value:
modules:
- id: snow_ticket
value:
type: rawscript
content: |
// import * as wmill from "windmill-client"

export async function main(x: string) {
return {error: "foo"}
}
language: bun
input_transforms:
x:
type: static
value: ""
assets: []
- id: a
value:
type: rawscript
content: |
// import * as wmill from "windmill-client"

export async function main(x: string) {
return x
}
language: bun
input_transforms:
x:
type: javascript
expr: >-
`Failed to create ServiceNow
ticket!\n\n${results.snow_ticket?.error}

`
assets: []
schema:
$schema: https://json-schema.org/draft/2020-12/schema
properties: {}
required: []
type: object
can you send me a similar extremely minimal flow with your issue please
Trey
TreyOP2w ago
sure thing ok I reproduced the issue:
edited_at: ""
edited_by: ""
extra_perms: {}
path: u/admin2/suave_flow
schema:
$schema: https://json-schema.org/draft/2020-12/schema
order: []
properties: {}
required: []
type: object
summary: ""
value:
modules:
- id: a
value:
assets: []
content: |
# import wmill


def main():
try:
pass
except:
return {"error": "test error"}
input_transforms: {}
language: python3
type: rawscript
- id: b
summary: ""
value:
branches:
- expr: results.a.error == null
modules: []
summary: Success
default:
- id: c
value:
assets: []
content: |-
# import wmill


def main(x: str):
print(x)
return x
input_transforms:
x:
expr: "`${results.a.error}`"
type: javascript
value: ${results.a.error}
language: python3
type: rawscript
type: branchone
edited_at: ""
edited_by: ""
extra_perms: {}
path: u/admin2/suave_flow
schema:
$schema: https://json-schema.org/draft/2020-12/schema
order: []
properties: {}
required: []
type: object
summary: ""
value:
modules:
- id: a
value:
assets: []
content: |
# import wmill


def main():
try:
pass
except:
return {"error": "test error"}
input_transforms: {}
language: python3
type: rawscript
- id: b
summary: ""
value:
branches:
- expr: results.a.error == null
modules: []
summary: Success
default:
- id: c
value:
assets: []
content: |-
# import wmill


def main(x: str):
print(x)
return x
input_transforms:
x:
expr: "`${results.a.error}`"
type: javascript
value: ${results.a.error}
language: python3
type: rawscript
type: branchone
so in the inline script if i return the object without the try/except, it works fine. but once i add a try/except i get the error:
nternalError: Error: TypeError: Cannot read properties of null (reading 'error')
at <anon>:18:29 @worker_flow.rs:1768:11
nternalError: Error: TypeError: Cannot read properties of null (reading 'error')
at <anon>:18:29 @worker_flow.rs:1768:11
its like the return type cant be inferred and confuses the system? but when i add a return value i.e string in the try block in the inline script, it works
rubenf
rubenf2w ago
in what you gave, you're not returning anything in step a
def main():
try:
pass
except:
return {"error": "test error"}
def main():
try:
pass
except:
return {"error": "test error"}
this will just pass
Trey
TreyOP2w ago
yes there are some scripts to where i only returned something if error. else none
rubenf
rubenf2w ago
sure but then it's normal results.a.error errors results.a is null as the error indicate
Trey
TreyOP2w ago
i assumed the ts expr would return 'undefined' if snow_ticket?.error was null?
rubenf
rubenf2w ago
maybe but that's not the reproduction you sent
Trey
TreyOP2w ago
apologies. I noticed that if i did not include a return of something in the above script and attempted to use a nested property of the result of the script, then it would give me the error
rubenf
rubenf2w ago
it gives you the error that results.a is null which it is and if you use results.a?.error it will work I need a reproduction where the engine is not working as intended, not where the error is the same but it's intended
Trey
TreyOP2w ago
correct. but i was hoping that the question mark (null-aware) would handle the possibility of the returned value being null
rubenf
rubenf2w ago
it does the reproduction needs to show a case where it doesn't
Trey
TreyOP2w ago
because even including the ? it was still giving me the error.
edited_at: ""
edited_by: ""
extra_perms: {}
path: u/admin2/suave_flow
schema:
$schema: https://json-schema.org/draft/2020-12/schema
order: []
properties: {}
required: []
type: object
summary: ""
value:
modules:
- id: a
value:
assets: []
content: |
# import wmill


def main():
try:
# return 'test one two three'
pass
except:
return {"error": "test error"}
input_transforms: {}
language: python3
type: rawscript
- id: b
summary: ""
value:
branches:
- expr: results.a?.error == null
modules: []
summary: Success
default:
- id: c
value:
assets: []
content: |-
# import wmill


def main(x: str):
print(x)
return x
input_transforms:
x:
expr: "`${results.a.error}`"
type: javascript
value: ${results.a.error}
language: python3
type: rawscript
type: branchone
edited_at: ""
edited_by: ""
extra_perms: {}
path: u/admin2/suave_flow
schema:
$schema: https://json-schema.org/draft/2020-12/schema
order: []
properties: {}
required: []
type: object
summary: ""
value:
modules:
- id: a
value:
assets: []
content: |
# import wmill


def main():
try:
# return 'test one two three'
pass
except:
return {"error": "test error"}
input_transforms: {}
language: python3
type: rawscript
- id: b
summary: ""
value:
branches:
- expr: results.a?.error == null
modules: []
summary: Success
default:
- id: c
value:
assets: []
content: |-
# import wmill


def main(x: str):
print(x)
return x
input_transforms:
x:
expr: "`${results.a.error}`"
type: javascript
value: ${results.a.error}
language: python3
type: rawscript
type: branchone
removed the returning value from try block updated branch predicate to "results.a?.error == null" and it gives me
InternalError: Error: TypeError: Cannot read properties of null (reading 'error')
at <anon>:18:29 @worker_flow.rs:1768:11
InternalError: Error: TypeError: Cannot read properties of null (reading 'error')
at <anon>:18:29 @worker_flow.rs:1768:11
rubenf
rubenf2w ago
Ok I can indeed reproduce, on it, thanks found the issue, fixed on latest commit. latest will be available to pull in 20mins and we will do a release and deploy tomorrow.
Trey
TreyOP2w ago
Awesome! Appreciate the help!

Did you find this page helpful?