Skip to content

Invalid interpolations are hard to debug #447

@pbrisbin

Description

@pbrisbin

I have a case where I need to perform a sed during a dry_run (because I need this update to apply before compilation of the binary being released), so I'm using the verify hook to do it.

Something like,

plugins:
  - - "@semantic-release/exec"
    - verifyConditionsCmd: |
        sed -i 's/^version:  .*$/version: ${nextRelease.version}/' package.yaml

This won't work because nextRelease is not defined yet, so the incorrect interpolation produces an error. Trouble is, it took forever for me to debug this, because this sort of failure produces no useful output:

[3:20:54 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/exec"
[3:20:54 PM] [semantic-release] › ✘  Failed step "verifyConditions" of plugin "@semantic-release/exec"
[3:20:54 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[3:20:54 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication (https://api.github.com/)
[3:20:54 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/github"
[3:20:54 PM] [semantic-release] › ⚠  Skip step "fail" of plugin "@semantic-release/exec" in dry-run mode
[3:20:54 PM] [semantic-release] › ⚠  Skip step "fail" of plugin "@semantic-release/github" in dry-run mode
[3:20:54 PM] [semantic-release] › ✘  EVERIFYCONDITIONS 
Error: AggregateError: 
    SemanticReleaseError
        at verifyConditions (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/v4/node_modules/@semantic-release/exec/index.js:17:13)
        at async validator (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/v4/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///home/runner/work/_actions/cycjimmy/semantic-release-action/v4/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async Promise.all (index 0)
        at async next (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/v4/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44)

I'm guessing it's because in this code,

    try {
      await exec("verifyConditionsCmd", pluginConfig, context);
    } catch (error) {
      throw new SemanticReleaseError(error.stdout, "EVERIFYCONDITIONS");
    }

error.stdout is empty, so nothing is seen.

I eventually figured out that I have to use verifyReleaseCmd for my use-case, but I think it's a bug that there is absolutely no output when this sort of interpolation failure occurs. Interpolation like this is generally error-prone, so good feedback seems important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions