Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous argument error - unclear why #20

Closed
dschach opened this issue Nov 14, 2022 · 4 comments
Closed

ambiguous argument error - unclear why #20

dschach opened this issue Nov 14, 2022 · 4 comments

Comments

@dschach
Copy link

dschach commented Nov 14, 2022

I get the feeling that it doesn't like my PMD rules. Eslint seems to dislike them too, but this is a tool that I'd expect to get it. I don't know what the diffBetweenCurrentAndParentBranch.txt file is - are you able to support incremental vs full scans?

Is it hurting because I have no Apex code and basically no metadata? It's a base project template so I have all the things I like set up the way I like them for new projects.

This is my workflow job:

pmd-spano-scanner:
    runs-on: ubuntu-latest
    needs: format-lint-lwc-tests
    if: ${{ github.actor != 'dependabot[bot]' }}
    steps:
      # Checkout the source code
      - name: 'Checkout source code'
        uses: actions/checkout@v3

      - name: Install SFDX CLI and Scanner
        run: |
          npm install sfdx-cli
          node_modules/sfdx-cli/bin/run plugins:install @salesforce/sfdx-scanner
      - name: Run SFDX Scanner - Report findings as comments
        uses: mitchspano/sfdx-scan-pull-request@v0.1.3
        with:
          pmdconfig: 'pmd/deployRules.xml'
          severity-threshold: 1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Error message:

Run mitchspano/sfdx-scan-pull-request@v0.1.3
  with:
    pmdconfig: pmd/deployRules.xml
    severity-threshold: 1
  env:
    GITHUB_TOKEN: ***
  
Getting difference within the pull request...
fatal: ambiguous argument 'origin/undefined...origin/undefined': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
node:child_process:8[2](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:2)6
    err = new Error(msg);
          ^

Error: Command failed: git diff origin/undefined...origin/undefined > diffBetweenCurrentAndParentBranch.txt
fatal: ambiguous argument 'origin/undefined...origin/undefined': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at getDiffInPullRequest (/home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1.[3](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:3)/index.js:78:3)
    at main (/home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1.3/index.js:280:3)
    at Object.<anonymous> (/home/runner/work/_actions/mitchspano/sfdx-scan-pull-request/v0.1.3/index.js:287:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:1[4](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:4))
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:11[5](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:5)3:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  status: 128,
  signal: null,
  output: [
    null,
    Buffer(0) [Uint8Array] [],
    Buffer(21[6](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:6)) [Uint8Array] [
      102,  9[7](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:7), 116,  9[7](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:8), 10[8](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:9),  58,  32,  [9](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:10)7, [10](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:11)9,  98, 105, 103,
      [11](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:12)7, 111, 117, 115,  32,  97, 114, 103, 117, 109, 101, 110,
      116,  32,  39, 111, 114, 105, 103, 105, 110,  47, 117, 110,
      100, 101, 102, 105, 110, 101, 100,  46,  46,  46, 111, 114,
      105, 103, 105, 110,  47, 117, 110, 100, 101, 102, 105, 110,
      101, 100,  39,  58,  32, 117, 110, 107, 110, 111, 119, 110,
       32, 114, 101, 118, 105, 115, 105, 111, 110,  32, 111, 114,
       32, 1[12](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:13),  97, 116, 104,  32, 110, 111, 116,  32, 105, 110,
       32, 116, 104, 101,
      ... 116 more items
    ]
  ],
  pid: 1949,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(216) [Uint8Array] [
    102,  97, 116,  97, 108,  58,  32,  97, 109,  98, 105, 103,
    117, 111, 117, 115,  32,  97, 1[14](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:15), 103, 117, 109, 101, 110,
    116,  32,  39, 111, 114, 105, 103, 105, 110,  47, 117, 110,
    100, 101, 102, 105, 110, 101, 100,  46,  46,  46, 111, 114,
    105, 103, 105, 110,  47, 117, 110, 100, 101, 102, 105, 110,
    101, 100,  39,  58,  32, 117, 110, 107, 110, 111, 119, 110,
     32, 114, 101, 118, 105, 1[15](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:16), 105, 111, 110,  32, 111, 114,
     32, 112,  97, 1[16](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:17), 104,  [32](https://github.com/dschach/BaseSFDXProject/actions/runs/3454017819/jobs/5765037153#step:4:33), 110, 111, 116,  32, 105, 110,
     32, 116, 104, 101,
    ... 116 more items
  ]
}
@mitchspano
Copy link
Owner

Thanks for raising this issue - do you have a link that you can share to the invocation of the GitHub action?

The diffBetweenCurrentAndParentBranch.txt is a text file which stores the difference between the branch you are trying to pull in and the branch you are trying to pull to. This .js template literal is where we concatenate the branch names into a git diff command to determine which files have changed as part of the pull request and populate that file.

execSync(
  `git diff origin/${this.pullRequest?.base?.ref}...origin/${this.pullRequest?.head?.ref} > ${DIFF_OUTPUT}`
)

source.

The fact that this evaluates to origin/undefined...origin/undefined makes it look like this action was executed outside of the scope of a pull request - hence the failure.

@dschach
Copy link
Author

dschach commented Nov 18, 2022 via email

@mitchspano
Copy link
Owner

Given that this action is called sfdx-scan-pull-request, I don't know if it needs to be usable outside of that scope. However, I will modify the action so that there is a clear error message in this scenario.

mitchspano added a commit that referenced this issue Nov 24, 2022
- Fix for issue #20
- Validates that the action was  invoked from the scope of a pull request
mitchspano added a commit that referenced this issue Nov 24, 2022
* Validate Pull Request Context

- Fix for issue #20
- Validates that the action was  invoked from the scope of a pull request
- Add Exit
@mitchspano
Copy link
Owner

Added an error which is thrown when the action is invoked outside the scope of a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants