kalup

Exit codes

The six exit codes every Kalup command uses, when each happens and how a script or agent should react.

Every Kalup command ends with one of six exit codes. They are fixed: a script can branch on them without reading any text. Check the exit code first, then read the JSON envelope for details.

CodeNameMeaning
0DoneThe command did what was asked. There may be warnings.
1ErrorSomething went wrong that is not about your config: no project, a bad flag, a network or HubSpot error.
2DifferencesOnly with --exit-code: the command found changes to make. Not a failure.
3InvalidThe config files are invalid. Nothing was written.
4Person neededNothing can go on until a person acts, for example a key that belongs to the wrong portal.
5PartialReserved for apply, which is not built yet: some writes succeeded and some did not.

When each happens

0: done

The command finished. Warnings, if any, are in issues with codes starting W_, and ok is true.

Every command can exit 0.

1: error

The problem is not in your config files. Common causes:

CodeCause
E_NO_CONFIGNo kalup.config.ts in this directory or any above it.
E_USAGEAn unknown command or flag, a flag without its value, or an unexpected argument.
E_NOT_IMPLEMENTEDA command this version does not have yet.
E_MISSING_KEY, E_AUTH, E_SCOPEThe read key is missing, rejected, or lacks a scope.
E_HTTP, E_UNREACHABLE, E_RATE_LIMIT, E_DAILY_LIMITHubSpot answered with an error, did not answer, kept rate-limiting, or the daily API limit is used up.
E_UNEXPECTEDAnything else. The message is one cleaned line.

Every command can exit 1.

2: differences

Only with --exit-code, and only together with --check. It means "there is work to do", so CI can fail a job on it. ok is still true.

CommandExits 2 when
kalup fmt --check --exit-codeA file is not in canonical form.
kalup pull --check --exit-codeThe portal has changes the files do not have yet.

Without --exit-code, the same situations exit 0.

3: invalid

The config files break the grammar or a rule. Nothing was written. The issues name the file, the line and the fix.

validate, ir, fmt, pull and status exit 3 on an invalid config.

4: person needed

Kalup stopped because only a person can decide. The issue has humanRequired: true. Today this happens when the key belongs to a different portal than the one pinned for the target (E_TARGET_PORTAL_MISMATCH): init, pull and status stop before reading anything.

Changing the pinned portalId to make the mismatch go away is never the fix. Someone has to check which key and which portal are right.

5: partial

Belongs to apply, which writes to a portal. apply is not in this version, so no command exits 5 today.

How to react

CodeA script or CI jobAn AI agent
0Go on.Go on. Mention any W_ warnings to the user.
1Fail the step and show the issues.Read the issue's fix. If it is about keys or network, tell the user; do not retry in a loop.
2Fail the check step, or run the command without --check to apply the changes locally.Run the same command without --check if the user wants the change, then validate.
3Fail the step.Apply each issue's fix to the named file and line, then run kalup validate --json again.
4Fail and ask a person to look.Stop. Show the user the issue text and wait. Do not change the config to get past it.
5Run plan again and review.Stop and tell the user. Do not retry the write.

In a shell

npx kalup validate --json > result.json
case $? in
  0) echo "valid" ;;
  3) echo "invalid config, see result.json"; exit 1 ;;
  *) echo "kalup failed, see result.json"; exit 1 ;;
esac

On this page