{"record":{"id":"7cd31c17e8d7f688","repo":"kestra-io/kestra","slug":"incorrect-s-format-must-be-a-number","errorCode":null,"errorMessage":"Incorrect %s format, must be a number","messagePattern":"Incorrect (.+?) format, must be a number","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/DateAddFilter.java","lineNumber":58,"sourceCode":"\n    public static Long getAsLong(Object value, int lineNumber, PebbleTemplate self) {\n        if (value instanceof Long longValue) {\n            return longValue;\n        } else if (value instanceof Integer integerValue) {\n            return integerValue.longValue();\n        } else if (value instanceof Number numberValue) {\n            return numberValue.longValue();\n        } else if (value instanceof String stringValue) {\n            try {\n                return Long.parseLong(stringValue);\n            } catch (NumberFormatException e) {\n                throw new PebbleException(\n                    e, \"%s can't be converted to long\".formatted(stringValue),\n                    lineNumber, self != null ? self.getName() : \"Unknown\"\n                );\n            }\n        }\n        throw new PebbleException(\n            null, \"Incorrect %s format, must be a number\".formatted(value),\n            lineNumber, self != null ? self.getName() : \"Unknown\"\n        );\n    }\n\n}\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/DateAddFilter.java#L40-L65","documentation":"Thrown by DateAddFilter.getAsLong when the 'amount' argument is not a Long, Integer, Number, or String — it falls through all type checks and reaches the final throw. This means the argument is a completely unexpected type such as Boolean, List, Map, or a custom object.","triggerScenarios":"Passing a non-numeric, non-string value as the amount to dateAdd: '{{ mydate | dateAdd(true, \"days\") }}', '{{ mydate | dateAdd(mylist, \"days\") }}', '{{ mydate | dateAdd(mymap, \"days\") }}'. The amount variable resolves to a complex type.","commonSituations":"A misconfigured variable whose value is a JSON object or array rather than a scalar. Passing a boolean from a conditional expression. Type drift in upstream outputs where a value that was once numeric becomes structured.","solutions":["Ensure the amount argument is a number or a numeric string.","If the value comes from a complex type, extract a scalar field first: '{{ mydate | dateAdd(mymap.days, \"days\") }}'.","Validate the variable type in the upstream task before it reaches the template."],"exampleFix":"{# before #}\n{{ execution.startDate | dateAdd(vars.config, \"days\") }}\n{# vars.config is a map #}\n\n{# after — extract scalar field #}\n{{ execution.startDate | dateAdd(vars.config.offset_days, \"days\") }}","handlingStrategy":"validation","validationCode":"{# Ensure amount is a scalar number before dateAdd #}\n{% set amt = vars.offset ?? 0 %}\n{% if amt is numeric %}\n  {{ date | dateAdd(amt, \"days\") }}\n{% endif %}","typeGuard":"{# Guard against complex types by extracting a scalar field #}\n{% set amt = vars.config.days_offset ?? 0 %}\n{{ date | dateAdd(amt, \"days\") }}","tryCatchPattern":null,"preventionTips":["Never pass a map, list, or boolean as the amount to dateAdd.","Extract scalar fields from complex variables before using them as filter arguments.","Validate the type of configuration variables that feed into date operations."],"tags":["pebble","dateadd-filter","type-mismatch","date"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}