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

"rfbrowser init" fails due to "UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data" after latest 19.1.0 release #3938

Closed
rafalrat opened this issue Dec 4, 2024 · 6 comments
Labels
bug Something isn't working priority: critical
Milestone

Comments

@rafalrat
Copy link

rafalrat commented Dec 4, 2024

Describe the bug
Our CI pipeline started failng few days ago due to problems with rfbrowser init command. We have discovered that it is due to the latest 19.1.0 version of robotframework-browser. After downgrading it to 19.0.1 initialization works fine. The issue does not seem to occur on Windows, but in our Docker image built on Ubuntu 22.04 (Jammy) it keeps failing (the Dockerfile for reproducing the bug is attached in the reproduction section). Below is the error stack trace when using the newest release:

    sys.exit(cli())
  File "/root/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/root/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/.local/lib/python3.10/site-packages/Browser/entry/__main__.py", line 488, in init
    raise err
  File "/root/.local/lib/python3.10/site-packages/Browser/entry/__main__.py", line 480, in init
    _rfbrowser_init(skip_browsers, silent_mode, with_deps, browser)
  File "/root/.local/lib/python3.10/site-packages/Browser/entry/__main__.py", line 280, in _rfbrowser_init
    _unix_process_executor_with_bar(
  File "/root/.local/lib/python3.10/site-packages/Browser/entry/__main__.py", line 187, in _unix_process_executor_with_bar
    message = output.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
The command '/bin/bash --login -i -c ~/.local/bin/rfbrowser init' returned a non-zero code: 1

image

To Reproduce
Steps to reproduce the behavior:

  1. Create requirements.txt with following dependencies:
robotframework == 7.1.1
robotframework-browser == 19.1.0
robotframework-requests == 0.9.7
  1. Build a docker image from the given Dockerfile (should be place in the same directory as requirements.txt):
FROM mcr.microsoft.com/playwright/python:v1.41.0-jammy

RUN pip install virtualenv

RUN apt-get update \
    && apt-get install -y ca-certificates curl gnupg \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get update \
    && apt-get install -y \
        nodejs \
        npm \
    && apt-get install -f -y \
    && apt-get clean


SHELL ["/bin/bash", "--login", "-i", "-c"]

# Install NVM in order to install NodeJS 20
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
RUN nvm install 20.9.0 && nvm use 20.9.0

# Install robotframework-browser
COPY requirements.txt /tmp/requirements.txt
RUN pip install --user -r /tmp/requirements.txt
RUN ~/.local/bin/rfbrowser init
  1. You will receive the error and the image will not be successfully built:
    image

  2. In the requirements.txt change the version of robotframework-browser to 19.0.1 and save:

robotframework-browser == 19.0.1
  1. Build again the docker image. It should be ok now:

image

Expected behavior
The rfbrowser init work and should not cause the docker build process failure when using the newest robotframework-browser version (otherwise we need to stick to an exact version, 19.0.1 in this case).

@rafalrat rafalrat changed the title "rfbrowser init" fails due to "UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data" "rfbrowser init" fails due to "UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data" after latest 19.1.0 release Dec 4, 2024
@fsmeier
Copy link

fsmeier commented Dec 4, 2024

+1

@spicard999
Copy link

same error on my side for the exact same reasons
I upated the base image to mcr.microsoft.com/playwright:v1.49.0-jammy
And it seems to have solved the problem

@rafalrat
Copy link
Author

rafalrat commented Dec 5, 2024

@spicard999 your solution works, thx 👍 I wonder if it is then an issue regarding the base image from MS or the issue is within the 19.1.0 release of the lib. Anyway, changing to mcr.microsoft.com/playwright:v1.49.0-jammy works as expected.

@Meraxa
Copy link

Meraxa commented Dec 5, 2024

Not sure if this relates directly to this topic but since version 19.1.0 poetry is no longer able to install the robotframework-browser package too.

I'm using the following configuration in my pyproject.toml.

[tool.poetry]
name = "test"
package-mode = false

[tool.poetry.dependencies]
python = "^3.10"
robotframework-browser = "19.1.0"

Which results in a Index Error - list index out of range error message from poetry during the version resolving.

Updating dependencies
Resolving dependencies... (1.8s)

  IndexError

  list index out of range

  at ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\repositories\http_repository.py:328 in _get_info_from_links
      324│                 return self._get_info_from_metadata(
      325│                     first_wheel
      326│                 ) or self._get_info_from_wheel(first_wheel)
      327│
    → 328│         return self._get_info_from_metadata(sdists[0]) or self._get_info_from_sdist(
      329│             sdists[0]
      330│         )
      331│
      332│     def _links_to_data(self, links: list[Link], data: PackageInfo) -> dict[str, Any]:

When I pin the version of robotframework-browser to 19.0.1 everything works fine again.

Addition:

When using any robotframework-browser version >=19.0.0, the rfbrowser init command seems to be not fully executed:

2024-12-05 13:35:37,957 [INFO    ] ==============================================================================================================
2024-12-05 13:35:37,957 [INFO    ] Installing node dependencies...
2024-12-05 13:35:38,048 [INFO    ] Installing rfbrowser node dependencies at /builds/<path>/.venv/lib/python3.10/site-packages/Browser/wrapper
2024-12-05 13:35:38,129 [INFO    ] npm warn config production Use `--omit=dev` instead.
2024-12-05 13:35:40,626 [INFO    ] 
2024-12-05 13:35:40,626 [INFO    ] added 81 packages, and audited 82 packages in 3s
2024-12-05 13:35:40,627 [INFO    ] 
2024-12-05 13:35:40,627 [INFO    ] 7 packages are looking for funding
2024-12-05 13:35:40,627 [INFO    ]   run `npm fund` for details
2024-12-05 13:35:40,627 [INFO    ] 
2024-12-05 13:35:40,628 [INFO    ] found 0 vulnerabilities
2024-12-05 13:35:40,646 [INFO    ] 
2024-12-05 13:35:40,646 [INFO    ] Installing browser binaries to /ms-playwright
2024-12-05 13:35:40,646 [INFO    ] npx --quiet playwright install
2024-12-05 13:35:41,479 [INFO    ] 
2024-12-05 13:35:41,480 [INFO    ] rfbrowser init completed
2024-12-05 13:35:41,480 [INFO    ] ==============================================================================================================

Usually, a bunch of dependencies are downloaded.
This in turn leads to error messages for any browser keywords used in the Robot test suite.

For version 18.9.1 things are working as usual.

@aaltat
Copy link
Member

aaltat commented Dec 8, 2024

Yes, some code from rfbrowser logging side was removed to make this bug resurface. We will try to get this fixed in the next hotfix release.

@aaltat aaltat added bug Something isn't working priority: critical labels Dec 8, 2024
@aaltat aaltat added this to the v19.1.1 milestone Dec 8, 2024
@aaltat
Copy link
Member

aaltat commented Dec 11, 2024

Fixed in #3951

@aaltat aaltat closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: critical
Projects
None yet
Development

No branches or pull requests

5 participants