Skip to content

playwright_integrity_map usability issues #40

@renesas-abigail

Description

@renesas-abigail

Version info

  • bazel v8.1.0
  • rules_playwright v0.5.3
  • playwright 1.57.0

Background

Thank you for creating this repository. I tried to use playwright_integrity_map but I encountered several issues.

This is my invocation.

# <repo_root>/BUILD

playwright_integrity_map(
    name = "playwright_integrity_map",
    browsers = playwright_browser_matrix(
        browser_names = [
            "firefox",
        ],
        platforms = [
            "mac15",
            "ubuntu24.04-x64",
            "ubuntu24.04-arm64",
        ],
        playright_repo_name = "playwright",
    ),
)

Issues found:

  1. Name of parameter in output is incorrect integrity_map vs actual integrity_path_map
  2. SHA-256 hash is hex digest but it must be base64 encoded. Refer to examples in known_browsers.bzl, which are correctly base 64 encoded vs hex sample output below.
  3. If the wrong hash value is used in integrity_path_map (such as the hex digests output by playwright_integrity_map), the integrity map cannot be regenerated because it needs to download the browser archive to check the hash which requires the integrity check to pass in the first place. This is probably intended behavior but the error message could be more clear. Because it's confusing to say 'invalid checksum' when what I'm trying to do is generate the checksums in the first place. Was more confusing before I figured out the checksums need to be converted to base64. See output below for sample.
# Output of bazel build //:playwright_integrity_map, does not work
integrity_map = {
  "builds/firefox/1497/firefox-ubuntu-24.04-arm64.zip": "sha256-ccd67b23644e1ad5e765e7fbf88d8f9756f71d9454292f6e3d6aacfc4aa6a749",
  "builds/firefox/1497/firefox-ubuntu-24.04.zip": "sha256-168e69855d6e49997823fe765d66f02720f6add035a9d3ac94e51073d391a272",
  "builds/firefox/1497/firefox-mac.zip": "sha256-1d8e8b4698e8d15c52864e84a7ca2e39e968e46da9140fc9e912d0e1c3932675"
}

# Actually working code (manually modified)
integrity_path_map = { # <-- different variable name
    "builds/firefox/1497/firefox-ubuntu-24.04-arm64.zip": "sha256-zNZ7I2ROGtXnZef7+I2Pl1b3HZRUKS9uPWqs/Eqmp0k=", # <-- base64 encode
    "builds/firefox/1497/firefox-ubuntu-24.04.zip": "sha256-Fo5phV1uSZl4I/52XWbwJyD2rdA1qdOslOUQc9ORonI=",
    "builds/firefox/1497/firefox-mac.zip": "sha256-HY6LRpjo0VxShk6Ep8ouOelo5G2pFA/J6RLQ4cOTJnU="
}

# Example showing issue #3, error is not clear
bazel build //:playwright_integrity_map

INFO: Invocation ID: redacted
INFO: Repository rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64 instantiated at:
  <builtin>: in <toplevel>
Repository rule http_file defined at:
  /home/redacted/.cache/bazel/_bazel_redacted/redacted/external/bazel_tools/tools/build_defs/repo/http.bzl:483:28: in <toplevel>
ERROR: /home/redacted/.cache/bazel/_bazel_redacted/redacted/external/bazel_tools/tools/build_defs/repo/http.bzl:179:33: An error occurred during the fetch of repository 'rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64':
   Traceback (most recent call last):
        File "/home/redacted/.cache/bazel/_bazel_redacted/redacted/external/bazel_tools/tools/build_defs/repo/http.bzl", line 179, column 33, in _http_file_impl
                download_info = ctx.download(
Error in download: Checksum error in repository @@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64: Invalid SHA-256 SRI checksum 'sha256-ccd67b23644e1ad5e765e7fbf88d8f9756f71d9454292f6e3d6aacfc4aa6a749'
ERROR: no such package '@@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64//file': Checksum error in repository @@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64: Invalid SHA-256 SRI checksum 'sha256-ccd67b23644e1ad5e765e7fbf88d8f9756f71d9454292f6e3d6aacfc4aa6a749'
ERROR: /home/redacted/.cache/bazel/_bazel_redacted/redacted/external/rules_playwright++playwright+playwright/browsers/BUILD.bazel:1232:14: @@rules_playwright++playwright+playwright//browsers:firefox-ubuntu24.04-arm64 depends on @@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64//file:file in repository @@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64 which failed to fetch. no such package '@@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64//file': Checksum error in repository @@rules_playwright++playwright+playwright-firefox-ubuntu24.04-arm64: Invalid SHA-256 SRI checksum 'sha256-ccd67b23644e1ad5e765e7fbf88d8f9756f71d9454292f6e3d6aacfc4aa6a749'
ERROR: Analysis of target '//:playwright_integrity_map' failed; build aborted: Analysis failed
INFO: Elapsed time: 6.438s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions