Skip to content

tasks: Use valid column when creating range for problem matcher#10509

Merged
msujew merged 1 commit intomasterfrom
msujew/fix-out-of-range-int
Dec 14, 2021
Merged

tasks: Use valid column when creating range for problem matcher#10509
msujew merged 1 commit intomasterfrom
msujew/fix-out-of-range-int

Conversation

@msujew
Copy link
Member

@msujew msujew commented Dec 6, 2021

What it does

When calling Range.create with a value larger than > 2^32-1, the function will throw an error. We do this when building ranges parsed from matched problems where we don't receive start/end columns:

range = Range.create(startLine, 1, startLine, Number.MAX_VALUE);

Number.MAX_VALUE is something like 10^308. Since Range.create always throws in this case, we never receive any matched problems from the server, and any errors are swallowed by a catch { return undefined }.

How to test

  1. Use this reproducible setup:

A file named test.js in the project root:

console.log('[DUMMY] WARNING test.js:1 This is a dummy warning')
console.log('[DUMMY] ERROR test.js:2 This is a dummy error')

A task definition like this:

{
  "label": "Test Matcher",
  "type": "shell",
  "command": "node",
  "args": [
    "test.js"
  ],
  "problemMatcher": {
    "name": "test-matcher",
    "owner": "test-matcher",
    "fileLocation": [
      "relative",
      "${workspaceFolder}"
    ],
    "pattern": {
      "regexp": "^\\[[A-Z]+\\] (INFO|WARNING|ERROR) (.*):(\\d+) (.*)$",
      "severity": 1,
      "file": 2,
      "line": 3,
      "message": 4
    }
  }
}
  1. Run the Test Matcher task
  2. Open test.js and assert that the first line is marked with a warning
  3. Assert that the second line is marked with an error

Review checklist

Reminder for reviewers

@msujew msujew added bug bugs found in the application tasks issues related to the task system labels Dec 6, 2021
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm the presence of the bug on master and the efficacy of this fix. 👍

@msujew msujew force-pushed the msujew/fix-out-of-range-int branch from 2716216 to ef36105 Compare December 7, 2021 11:23
@msujew msujew merged commit 5376a3b into master Dec 14, 2021
@msujew msujew deleted the msujew/fix-out-of-range-int branch December 14, 2021 13:06
@github-actions github-actions bot added this to the 1.21.0 milestone Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug bugs found in the application tasks issues related to the task system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants