Unable to run javascript enrichment in PUBSUB Enrich

{“schemaKey”:“iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0”,“identifier”:“Javascript enrichment”},“message”:{“error”:“Error compiling JavaScript function: [Cannot invoke “javax.script.Compilable.compile(String)” because the return value of “com.snowplowanalytics.snowplow.enrich.common.enrichments.registry.JavascriptScriptEnrichment.engine()” is null]”}

my javascript config file is :

{

"schema": "iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0",

"data": {

    "vendor": "com.snowplowanalytics.snowplow",

    "name": "javascript_script_config",

    "enabled": true,

    "parameters": {

        "script": "ZnVuY3Rpb24gcHJvY2VzcyhldmVudCkgewogICAgdmFyIGFwcElkID0gZXZlbnQuZ2V0QXBwX2lkKCk7CiAgCiAgICBpZiAoYXBwSWQgIT0gInB1YnN1Yl9lbnJpY2hfdGVzdCIpIHsKICAgICAgICB0aHJvdyAiU2VydmVyLXNpZGUgZXZlbnQgaGFzIGludmFsaWQgYXBwX2lkOiAiICsgYXBwSWQ7CiAgICB9CiAgCiAgICByZXR1cm4gWyB7IHNjaGVtYTogImlnbHU6Y29tLm1jZF9qYS91c2VyX2RldGFpbHMvanNvbnNjaGVtYS81LTAtMCIsCiAgICAgICAgICAgICAgIGRhdGE6ICB7ICJ1c2VyX2lkIjogInNpdmEiLCJhZ2UiOjM1LAonZ2VuZGVyJzoibWFsZSIgfSB9IF07Cn0K"

    }

}

}

Hi @Jitender_Attri

I’ve tested your config above within the latest version of Snowplow Mini and it works as expected

e.g. When having an invalid app_id:

Couple of things to check:

  • Your config file must be called javascript_script_enrichment.json.
  • Newer versions of enrich use a newer JS Engine to run the enrichment, you should check you are on a recent version.
  • There are some syntax inconsistencies in the above base64 JavaScript, you might want to just tidy that up (looking at the quotes in the returned schema for example). This shouldn’t cause any issues as it’s still technically correct but worth checking if on an older version of enrich.

did you try with pubsub enrich and beam enrich . i am facing this issue on punsub enrich

getting the same error
{“schemaKey”:“iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0”,“identifier”:“Javascript enrichment”},“message”:{“error”:“Error compiling JavaScript function: [Cannot invoke "javax.script.Compilable.compile(String)” because the return value of “com.snowplowanalytics.snowplow.enrich.common.enrichments.registry.JavascriptScriptEnrichment.engine()” is null]"}}]},"

I think thier is some error on pubsub enrich default config . Deployed on app engine

com.snowplowanalytics.snowplow.enrich.common.enrichments.registry.JavascriptScriptEnrichment.engine()” is null

getting error in javascript enrichment

":{“timestamp”:“2021-09-29T11:10:00.536670108Z”,“messages”:[{“enrichment”:{“schemaKey”:“iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0”,“identifier”:“Javascript enrichment”},“message”:{“error”:“Error compiling JavaScript function: [Cannot invoke “javax.script.Compilable.compile(String)” because the return value of “com.snowplowanalytics.snowplow.enrich.common.enrichments.registry.JavascriptScriptEnrichment.engine()” is null]”}}]},