I found a bug that I'm not sure if it's in statecharts, guardrails, or malli. If you invoke an external service with a non-keyword id and call (runtime/session-data env session-id) you get an error when guardrails is enabled. I have an SSCCE here: https://github.com/evaogbe/statecharts-invoke-bug Also keyword ids don't work with done.invoke.[invokeid] but that one is less of a bug and more of a gotcha that should be documented.
Also the statecharts docs say that the invoke type defaults to statechart when left out, but in actuality the type key is required
That makes sense. I think there's an extend-key function that can help with the done.invoke.[id] keyword conversion
yes, I beleive I’ve written such a thing more than once 😛
I found a patch for the bug but I still don't know the root cause
- (>def ::sc/elements-by-id [:map-of keyword? ::sc/element])
+ (>def ::sc/elements-by-id [:map-of ::sc/id ::sc/element])It's wrong in both the clojure spec and the malli spec
ah, yes, that should be fixed in the specs
If GR is enabled, then using a non-keyword element ID in the statechart will cause failures
not sure why that spec would affect invocations only though, or how an element would be created with such an ID just from invocation alone
It might not be invocation specific. I discovered it while doing invocations because I needed non-keyword ids to work with done.invoke[id]. com.fulcrologic.statecharts.runtime uses malli specs, which might be why it wasn't broken elsewhere
ok, well, if changing that spec fixes it, then that certainly looks like a valid fix to me
I've sent in PRs with the fixes
not terribly surprised. invocation support is sort of platform specific and I’ve not heavily hammered on it.
I think either the docs need to be updated or the code needs to be fixed to match the docs. I can send in a PR for the direction you'd prefer
Yeah, I probably should not have used keywords for the done.invoke stuff. Perhaps if a keyword is used (the specs support keyword) we should call name on it for the event invokeid, or some such conversion 😕
session IDs are spec’d to support UUID, string, numbers, and keywords. But the creation of events that are based on these IDs don’t work well this way. Event names are definitely wired to keywords, so some kind of standard transform needs to apply. Session ID of :x.y.z/id -> :done.invoke.x.y.z/id ?