danger / danger/danger-js

Invalid Mapping

Open
#501 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.5k
Forks
381
Avg merge
2h 8m
Merged PRs (30d)
6

Description

I'm getting this error when trying to run danger (both 'danger pr' and 'danger ci'):

```
Error: { Error: dangerfile.js: Invalid mapping: {"generated":{"line":3,"column":0},"source":null,"original":{"line":1,"column":0}}
at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/adarlocker/Documents/gefen/node_modules/source-map/lib/source-map-generator.js:289:13)
at SourceMapGenerator_addMapping [as addMapping] (/Users/adarlocker/Documents/gefen/node_modules/source-map/lib/source-map-generator.js:101:16)
at Array.forEach ()
at SourceMap.get (/Users/adarlocker/Documents/gefen/node_modules/babel-generator/lib/source-map.js:49:25)
at Object.get [as map] (/Users/adarlocker/Documents/gefen/node_modules/babel-generator/lib/buffer.js:53:33)
at File.generate (/Users/adarlocker/Documents/gefen/node_modules/babel-core/lib/transformation/file/index.js:710:26)
at File.transform (/Users/adarlocker/Documents/gefen/node_modules/babel-core/lib/transformation/file/index.js:554:17)
at /Users/adarlocker/Documents/gefen/node_modules/babel-core/lib/transformation/pipeline.js:50:19
at File.wrap (/Users/adarlocker/Documents/gefen/node_modules/babel-core/lib/transformation/file/index.js:564:16)
at Pipeline.transform (/Users/adarlocker/Documents/gefen
```

The only solution I could find for now (and only locally) is commenting the relevant lines inside node_modules (bolded):

```
SourceMapGenerator.prototype.addMapping =
function SourceMapGenerator_addMapping(aArgs) {
var generated = util.getArg(aArgs, 'generated');
var original = util.getArg(aArgs, 'original', null);
var source = util.getArg(aArgs, 'source', null);
var name = util.getArg(aArgs, 'name', null);

**// if (!this._skipValidation) {
// this._validateMapping(generated, original, source, name);
// }**

if (source != null) {
source = String(source);
if (!this._sources.has(source)) {
this._sources.add(source);
}
}

if (name != null) {
name = String(name);
if (!this._names.has(name)) {
this._names.add(name);
}
}

this._mappings.add({
generatedLine: generated.line,
generatedColumn: generated.column,
originalLine: original != null && original.line,
originalColumn: original != null && original.column,
source: source,
name: name
});
};
```
Any suggestions? Is it a known issue? I couldn't find any open issue related.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the error with `danger pr` and `danger ci`, then read `dangerfile.js` and the stack-trace entry points `node_modules/source-map/lib/source-map-generator.js` and `node_modules/babel-generator/lib/source-map.js`. Trace the invalid mapping and verify that both commands complete without the error.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.