-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix step state incorrect type
when returning null from steps
#96
base: main
Are you sure you want to change the base?
Conversation
Should fix the `step state incorrect type` that was being thrown when a step returns a null result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a showcase poc of the bug, I'll be dropping the commit before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (stepResult != null) { | ||
return stepResult | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we inadvertently introduced this bug with #19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe it was always present because even the older version check returns false
when type checking a null
result, because null
can never be a specific type:
val stepResult = state.getState<T>(hashedId)
if (stepResult is T) {
i made sure it's the case with this generic example:
inline fun <reified T> isOfType(value: Any?): Boolean {
return value is T
}
fun main() {
println(isOfType<String>(null))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks for verifying
stepResult.has(fieldName) -> deserializeStepData(stepResult.get(fieldName), type) | ||
stepResult.has("error") -> throw mapper.treeToValue(stepResult.get("error"), StepError::class.java) | ||
// NOTE - Sleep steps will be stored as null | ||
stepResult is NullNode -> null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Should fix the
step state incorrect type
that was beingthrown when a step returns a
null
result.Changes:
Allow returning a
null
value from thedata
field of a step forstep.run
.Make sure the
data
field is anull
json node forstep.sleep
. Here's the memoized state payload sent to the JS sdk which the Kotlin code is closely following:Checklist
Related
https://inngest.slack.com/archives/C06KB85RXRV/p1736536607871969