Troubleshooting
Cold start fails (every request 502)
| Log line | Cause → fix |
|---|---|
|
The secret is not named |
|
The key is missing from |
|
Neither |
|
Something imported |
Requests fail
-
All requests 400
Unauthorized— the internal API’stoken/validaterejected the token (a token from another environment, or expired),PAYABILITY_INTERNAL_API_URLis unreachable from the function, orX-Session-Tokenis missing. -
404 for every path in production —
event["path"]does not start with/actionstools: the custom domain base path mapping changed (request-lifecycle.adoc#paths). -
Timeouts on tasks, settings or notifications — the call to the Payability internal API hangs. Check the function still has its VPC config and the subnets have a route to that API.
-
400
Unable to parse JWT tokenwith403fromtoken/validate— the function is callingstaging.dev.payability.comfrom a public Lambda IP. Stage must use the dev VPC intemplate.yaml. -
CORS errors in the browser — preflight is answered by API Gateway; check the
Corsblock intemplate.yamllists the header the UI added.
Background work does not happen
-
Is
WORKER_FUNCTION_NAMEset on the API function? Without it, tasks run inline (slow, but they run). -
API log
AccessDeniedException … lambda:InvokeFunction— theLambdaInvokePolicyis missing. -
API log
RequestEntityTooLargeException— the task arguments exceed 256 KB; pass ids, not objects. -
Worker log
Unrecognised worker eventorRefusing to run task outside actionstools_app.— the payload was built by hand or the function moved; checktask_path. -
Worker log
RuntimeError: Working outside of request context— the task reads Flaskrequest. Known case:async_create_task(task creation with_mode: async). -
Slack only:
User … cannot be found on slack— the recipient’s Slack profile email differs from the CRM email.
Grid counts are wrong
-
Make sure exactly one consumer is enabled on the tasks stream (
aws lambda list-event-source-mappings --event-source-arn <stream arn>). -
Reset: invoke the Worker with
{"action": "remove_counters"}; counts are recalculated on the next request (Task counters).
Build and local issues
-
UnauthorizedSSOTokenErroron import — local runs try to read Secrets Manager. Runaws sso login --profile devor setAWS_SECRETS_MANAGER=False. -
sam build:Could not satisfy the requirement: setuptools— pip cannot reach its index. A global pip config pointing at CodeArtifact with an expired token is the usual cause:PIP_INDEX_URL=https://pypi.org/simple make build, or refresh the CodeArtifact login. -
sam build:Unable to retrieve name/version for package: pyb-flask-utils— SAM ran outsideuv runand found no usablepython3.12. Usemake build. -
uv sync: authentication failed for github.com/Payability — configure git credentials for the private repos (CI uses thePYB_GITHUB_TOKENorganisation secret in aurl.insteadOfrule). In CI,could not read Password for 'https://github.com'means that secret was empty.