Skip to content

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

Description

@Toxicable

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}

Activity

  1. bcoe commented on Jan 6, 2021

    @bcoe
    Owner

    @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?

  2. Toxicable commented on Jan 7, 2021

    @Toxicable
    ContributorAuthor

    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.

  3. Toxicable commented on Jan 9, 2021

    @Toxicable
    ContributorAuthor

    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
        ```
    
  4. bcoe commented on Jan 9, 2021

    @bcoe
    Owner

    @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?

  5. Toxicable commented on Jan 9, 2021

    @Toxicable
    ContributorAuthor

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

  6. bcoe commented on Jan 14, 2021

    @bcoe
    Owner

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions