feat: return CLI exit codes for remote functions#6025
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28b323f7c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| throw new RemoteFunctionError({ code: 'dryrun_error', message: dryrunErrorOutput, status: 400 }); | ||
| } | ||
|
|
||
| return { output: getDryrunCommandSuccessOutput({ stdout: result.stdout, stderr: result.stderr }) }; |
There was a problem hiding this comment.
Preserve zero-exit dryrun error detection
This now treats every nango dryrun exit-0 result as success, but our sandbox runtime can run a CLI build that still reports dryrun failures only in stderr while exiting 0 (the removed fallback explicitly handled this compatibility case). In that rollout window, failed dryruns will be returned as successful output instead of dryrun_error, which can produce false-positive test/preview results for users. Please keep a stderr/content-based fallback (or gate this on verified CLI version) until all runtimes are guaranteed to emit the new non-zero exit codes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is experimental API, some breakage during deployment is fine.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50bb5b1b95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| switch (getCommandExitCode(error)) { | ||
| case NANGO_CLI_COMPILE_ERROR_EXIT_CODE: | ||
| return 'compilation_error'; | ||
| case NANGO_CLI_DEPLOY_ERROR_EXIT_CODE: | ||
| default: |
There was a problem hiding this comment.
Keep compile fallback when deploy exits with unknown code
getDeployErrorCode now defaults every non-10 exit to deployment_error, so a deploy compile failure from a runtime that still exits with generic code 1 will be mislabeled even when the output clearly contains typecheck errors. Before this change, invokeDeploy/invokeLocalDeploy used output-based detection as a compatibility fallback; removing it regresses error classification during mixed CLI-runtime rollouts and can send users down the wrong remediation path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
2 issues found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/cli/lib/index.ts">
<violation number="1" location="packages/cli/lib/index.ts:417">
P1: Avoid `process.exit(...)` here; it can truncate pending stdout/stderr output. Set `process.exitCode` and return so output flushes before exit.</violation>
<violation number="2" location="packages/cli/lib/index.ts:419">
P1: Do not force `process.exit(0)` on success; it can cut off stdout output needed by callers. Return naturally (or set `process.exitCode = 0` then return).</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1b02bc7b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import type { FunctionErrorCode } from '@nangohq/types'; | ||
|
|
||
| // Keep in sync with packages/cli/lib/exit-codes.ts. | ||
| export const NangoCliExitCode = { |
There was a problem hiding this comment.
I couldn't find a good place to put this so that it's shared between the CLI and the server so I'm keeping it duplicated for now. Candidate packages were:
shared- this isn't really "shared" between all packages but mostly backend packagesutils- this isn't published so it would require publishing it or bundling the whole thing into the CLI. It has a lot of heavy stuff inside so not worth it for 3 constants.types- these are runtime constants, not types, so not a good fitserver- Don't want to import all of server inside the CLIrunner-sdk- The best existing candidate since the CLI already imports it, but the error codes are used by the server and cli, not runner-sdk
An alternative would be a new package but I don't think it's worth it for 3 constants.
There was a problem hiding this comment.
Always a bit of a pain. I think we need to create an actually shared package eventually. Webapp as the same problem requiring duplication
1746fd8 to
86ab5dd
Compare
Adds explicit CLI exit codes for compile, dryrun, and deploy failures so remote-functions can classify E2B/Docker command failures from exit codes instead of output regexes. Dryrun service methods now return Result values, and remote/local dryrun and deploy clients use CLI exit-code mapping while preserving stdout-only success parsing.
NAN-5373