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

Report not able to handle base64 files when using all: true #280

Closed
Toxicable opened this issue Jan 5, 2021 · 6 comments · Fixed by #283
Closed

Report not able to handle base64 files when using all: true #280

Toxicable opened this issue Jan 5, 2021 · 6 comments · Fixed by #283
Labels

Comments

@Toxicable
Copy link
Contributor

Reports aren't able to read base64 source maps files
Looking at this line here: https://github.com/bcoe/c8/blob/master/lib/report.js#L189
It's not able to read files which have their content encoded as a base64 path.
Example: path/to/file:application/json;base64,{base64 content}

Right now it'll throw an error like:

ENAMETOOLONG: name too long, open path/to/file:application/json;base64,{base64 content}

@bcoe
Copy link
Owner

bcoe commented Jan 6, 2021

@Toxicable interesting, if I'm understanding properly, this would be an artifact of running in a Bazel environment?

If we see a path in this format should we simply decode the base64 blob, rather than reading the file path? Any chance you could send a failing test?

@Toxicable
Copy link
Contributor Author

Correct, something about how bazel + typescript is configured results in these paths.
Although this should be reproducable with just plain TS, since under the hood it's still just running tsc
I'll reproduce it on the open source repository tonight and post here with a more a complete log output.

@Toxicable
Copy link
Contributor Author

Aight was able to reproduce it https://github.com/Toxicable/rules_nodejs/tree/path-issue , here's the full error:

(node:62) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'packages/jasmine/test/data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9uX2NvdmVyZWRfZmlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2phc21pbmUvdGVzdC9ub25fY292ZXJlZF9maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxTQUFTLFlBQVksQ0FBQyxLQUFhO0lBQy9CLE9BQU8sS0FBSyxHQUFHLENBQUMsQ0FBQztBQUNyQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZnVuY3Rpb24gc29tZUNvdmVyYWdlKGlucHV0OiBudW1iZXIpIHtcbiAgICByZXR1cm4gaW5wdXQgKyAzOyBcbn0iXX0'
    at Object.openSync (fs.js:440:3)
    at readFileSync (fs.js:342:35)
    at node_modules/c8/lib/report.js:175:78
    at Array.forEach (<anonymous>)
    at Report._getMergedProcessCov (node_modules/c8/lib/report.js:167:41)
    at Report.getCoverageMapFromAllCoverageFiles (node_modules/c8/lib/report.js:66:31)
    at Report.run (node_modules/c8/lib/report.js:46:31)
    at internal/coverage/lcov_merger-js.js:68:14
    at Generator.next (<anonymous>)
    at internal/coverage/lcov_merger-js.js:8:71
    ```

@bcoe
Copy link
Owner

bcoe commented Jan 9, 2021

@Toxicable it looks like I can just decode the base64:

'{"version":3,"file":"non_covered_file.js","sourceRoot":"","sources":["../../../../../../packages/jasmine/test/non_covered_file.ts"],"names":[],"mappings":";AAAA,SAAS,YAAY,CAAC,KAAa;IAC/B,OAAO,KAAK,GAAG,CAAC,CAAC;AACrB,CAAC","sourcesContent":["function someCoverage(input: number) {\\n    return input + 3; \\n}"]}'

That path looks pretty weird though no?

@Toxicable
Copy link
Contributor Author

Yeah that's correct. That path is meant to look a bit weird :P

@bcoe
Copy link
Owner

bcoe commented Jan 14, 2021

@Toxicable I'll make an effort to pick this up soon, would also happily take a patch. I was figuring that I'd detect file paths that look like this, and use the Base64 encoded value -- ignoring the start of the path.

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

Successfully merging a pull request may close this issue.

2 participants