`startColumn must be greater than or equal to 1` message should report offset for error

Open
#1,715 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
github-actions, typescript
Domain
ci-cd

Research direction

Start with the validation failure in upload-lib.js at lines 201 and 251, then trace how upload-sarif-action.js reports schema errors. Reproduce the linked SARIF upload failure and identify where the offending offset and surrounding content can be surfaced. Done means invalid startColumn and endColumn values produce actionable location details instead of only the minimum constraint message.

Written by the indexing model from the issue text.

Description

This run generated a not particularly helpful message:
https://github.com/check-spelling/gnu-gnulib/actions/runs/5151289440/jobs/9276309000#step:2:15096


Uploading results
  Processing sarif files: ["/tmp/tmp.Ba0HZNhBK7.sarif.json"]
Error details: instance.runs[0].results[0].locations[0].physicalLocation.region.startColumn must be greater than or equal to 1
  {
    "path": [
      "runs",
      0,
      "results",
      0,
      "locations",
      0,
      "physicalLocation",
      "region",
      "startColumn"
    ],
    "property": "instance.runs[0].results[0].locations[0].physicalLocation.region.startColumn",
    "message": "must be greater than or equal to 1",
    "schema": {
      "description": "The column number of the first character in the region.",
      "type": "integer",
      "minimum": 1
    },
    "instance": 0,
    "name": "minimum",
    "argument": 1,
    "stack": "instance.runs[0].results[0].locations[0].physicalLocation.region.startColumn must be greater than or equal to 1"
  }
Error details: instance.runs[0].results[0].locations[0].physicalLocation.region.endColumn must be greater than or equal to 1
  {
    "path": [
      "runs",
      0,
      "results",
      0,
      "locations",
      0,
      "physicalLocation",
      "region",
      "endColumn"
    ],
    "property": "instance.runs[0].results[0].locations[0].physicalLocation.region.endColumn",
    "message": "must be greater than or equal to 1",
    "schema": {
      "description": "The column number of the character following the end of the region.",
      "type": "integer",
      "minimum": 1
    },
    "instance": 0,
    "name": "minimum",
    "argument": 1,
    "stack": "instance.runs[0].results[0].locations[0].physicalLocation.region.endColumn must be greater than or equal to 1"
  }
Error: Unable to upload "/tmp/tmp.Ba0HZNhBK7.sarif.json" as it is not valid SARIF:
- instance.runs[0].results[0].locations[0].physicalLocation.region.startColumn must be greater than or equal to 1
- instance.runs[0].results[0].locations[0].physicalLocation.region.endColumn must be greater than or equal to 1
Error: Unable to upload "/tmp/tmp.Ba0HZNhBK7.sarif.json" as it is not valid SARIF:
- instance.runs[0].results[0].locations[0].physicalLocation.region.startColumn must be greater than or equal to 1
- instance.runs[0].results[0].locations[0].physicalLocation.region.endColumn must be greater than or equal to 1
    at validateSarifFileSchema (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:201:15)
    at uploadFiles (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:251:9)
    at Object.uploadFromActions (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:137:18)
    at async run (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-sarif-action.js:48:30)
    at async runWrapper (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-sarif-action.js:70:9)

The json is available here: https://github.com/check-spelling/gnu-gnulib/suites/13318061458/artifacts/727508547

Ideally when reporting issues, at a minimum, a line / character offset should be reported, and unless there's a risk of binary output breaking things, a substring showing the offending content in context would be appreciated. (I'm sure I can find the item(s), but I shouldn't have to search through an 850k file to find the problem.

Fwiw, here's the relevant snippet, and it'd be really much nicer if I didn't have to try to search for it (especially because I can't actually search for startColumn:0, I have to remember to search for startColumn":0 -- and if I'm less familiar w/ the json -- which anyone other than me would be -- then I wouldn't know if I need to consider optional whitespace..).

[{"ruleIndex":0,"ruleId":"bad-regex","message":{"text":"Bad regex. \\(bad-regex\\)"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":".github/actions/spelling/patterns.txt","uriBaseId":"%SRCROOT%"},"region":{"startLine":89,"startColumn":0,"endColumn":0}}}]}]
Dominant language
TypeScript
Stars
1.6k
Forks
493
Avg merge
1d 13h
Merged PRs (30d)
44

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql-action

All issues in github/codeql-action

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.