Skip to content

fix: add missing throw before messages.createError() calls#1548

Open
ZLeventer wants to merge 1 commit intosalesforcecli:mainfrom
ZLeventer:fix/missing-throw-errors
Open

fix: add missing throw before messages.createError() calls#1548
ZLeventer wants to merge 1 commit intosalesforcecli:mainfrom
ZLeventer:fix/missing-throw-errors

Conversation

@ZLeventer
Copy link
Copy Markdown

Summary

Two locations call messages.createError() but never throw the result, silently swallowing errors and allowing execution to continue past conditions that should halt.

src/commands/project/deploy/cancel.ts:88

// before
messages.createError('error.CannotCancelDeployPre', [jobId, deployOpts.status]);

// after
throw messages.createError('error.CannotCancelDeployPre', [jobId, deployOpts.status]);

When a deployment is already in a terminal state (Canceled, Failed, Succeeded, SucceededPartial), this guard is supposed to prevent the cancel attempt. Without throw, the error is created and discarded, and the cancel proceeds on an already-finished job.

src/utils/convertBehavior.ts:63

// before
messages.createError('error.noTargetTypes', [preset]);

// after
throw messages.createError('error.noTargetTypes', [preset]);

When getPackageDirectoriesForPreset finds no matching component sets for the given preset, it should surface a noTargetTypes error. Without throw, the error is dropped and the function silently returns an empty array.

Both cases follow the same throw messages.createError(...) pattern used consistently everywhere else in the codebase.

Test plan

  • yarn build passes
  • Existing tests pass
  • Manual test: cancel a completed deployment — should now surface the expected error instead of attempting to cancel

Two locations create an SfError but silently discard it instead of
throwing, so error conditions are swallowed and execution continues:

- deploy/cancel.ts:88 — when the deployment is already in a terminal
  state (Canceled/Failed/Succeeded), the guard creates the error but
  never throws it, allowing the cancel attempt to proceed on a finished job

- convertBehavior.ts:63 — when getPackageDirectoriesForPreset finds no
  matching component sets, the error is created and dropped; the function
  returns an empty array instead of surfacing the failure to the caller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant