zitadel / actions

ZITADEL Actions - Easy extensibility with custom code. Think GitHub Actions in an Identity System.
https://zitadel.com
25 stars 6 forks source link

Can't find function in action #22

Closed DerStimmler closed 8 months ago

DerStimmler commented 8 months ago

Hi, I created an action which should just log the text "Test".

So in the zitadel console I created an action "Logging" with the following content:

let logger = require("zitadel/log")

function log(ctx, api) {
    logger.log("Test");
}

The trigger is "Pre Userinfo creation" in "Complement Token" flow.

Now when I login into my application I can see in the zitadel logs that the action gets triggered but can't be executed because the function can't be found. This is the error log:

time="2023-11-07T16:51:23Z" level=info msg="log record emitted" caller="/home/runner/work/zitadel/zitadel/internal/logstore/emitters/stdout/stdout.go:19" record="{\"logDate\":\"2023-11-07T16:51:23.9405086Z\",\"took\":0,\"message\":\"action run started\",\"logLevel\":\"info\",\"instanceId\":\"237799571953025027\"}"
time="2023-11-07T16:51:23Z" level=info msg="log record emitted" caller="/home/runner/work/zitadel/zitadel/internal/logstore/emitters/stdout/stdout.go:19" record="{\"logDate\":\"2023-11-07T16:51:23.9406768Z\",\"took\":168300,\"message\":\"action run failed: function not found\",\"logLevel\":\"error\",\"instanceId\":\"237799571953025027\"}"

I've tried different function names, formatting, other modules (e.g. zitadel/http), but can't get the actions to work properly. Any ideas on how to solve this issue?

I'm running zitadel v2.38.2 in docker.

hifabienne commented 8 months ago

hei @DerStimmler Does the function name in the script have the same name as the function itself? At the moment those have to match.

DerStimmler commented 8 months ago

Hi @hifabienne, the name was different. After renaming the function to the action name it works.

Seems like I missed this line in the documentation 😅

The name of the action must corelate with the javascript function in the code section. This function will be called by ZITADEL.

Thanks for your help!