robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[BUG] Request textDocument/formatting failed

Open Abe210 opened this issue 7 months ago • 3 comments

Describe the bug I don't know if this bug/issue is related to RobotCode or the underlying robotidy/robocop used. In my case, I use both robocop and robotidy, here is my pyproject.toml:

[tool.poetry]
name = "...."
version = "...."
description = "...."
authors = []
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.10"
robotframework = "^7.3.2"
robotframework-browser = "^19.6.1"
robotframework-requests = "^0.9.7"
robotframework-pabot = "^4.2.0"
robotframework-robocop = "^5.5.0"
robotframework-tidy = "^4.14.0"
robotframework-debugger = "^0.2.1"
playwright = "^1.53.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.robocop]
configure = [
    "line-too-long:line_length:180",
    "too-long-keyword:max_len:80",
    "too-many-arguments:max_args:10",
    "too-many-calls-in-keyword:max_calls:20",
    "file-too-long:max_lines:800",
]
exclude = [
    "no-global-variable",
]

[tool.robotidy]
spacecount = 4
indent = 4
continuation-indent = 4
line_length = 180
separator = "space"
diff = false
overwrite = true
verbose = false
configure = [
    "AddMissingEnd:enabled=True",
]

Whenever there is an emoji or icon (usually added by copilot), the reformat document seems to break. Error message: Robotcode Request textDocument/formatting failed.Message: 'utf-8' codec can't encode character '\udd00' in position 3102: surrogates not allowed

Steps To Reproduce Steps to reproduce the behavior:

  1. Add � inside any .robot or .resource
  2. Enable format document on save in Vscode
  3. Save the document with the icon
  4. See error

If possible add some example source code like:

***Test Cases***
a simple test
    Log    �  Something    # this should show the icon the logs

Expected behavior The format document to work without any errors.

Desktop (please complete the following information):

  • VS Code Version: Visual Studio Code - Insiders v1.103.0-insider
  • RobotCode Version: 1.5.0
  • OS: Windows
  • Python Version: 3.12.4
  • RobotFramework Version: 7.3.2
  • Additional tools like robocop, robotidy: please look at the pyproject.toml provided

Abe210 avatar Jul 23 '25 23:07 Abe210

Which RoboCop version do you use?

robotidy is now deprecated and part of robocop. and also RobotCode has deprecated the use of robotidy. Did you try that already?

Does this also happens when you run robocop on the commandline? Maybe the file encoding is not correct, robot framework does only support utf8 encoded files.

d-biehl avatar Jul 29 '25 19:07 d-biehl

any news here?

d-biehl avatar Aug 20 '25 17:08 d-biehl

Sorry for the late reply, and thanks for keeping up with the issues. I really appreciate this extension and the time you've put in to release this for us :pray: The version used are:

robotframework-robocop = "^5.5.0"
robotframework-tidy = "^4.14.0"

You are absolutely correct about the file encoding not supporting utf16. I found a similar issue in the robotframework-lsp extension

For now, I just removed the emojis and the formatting works properly.

As for the deprecation of robotidy, I know that robotidy has been deprecated. I never upgraded robocop because I didn't have time to adapt the syntax of:

[tool.robotidy]
spacecount = 4
indent = 4
continuation-indent = 4
line_length = 180
separator = "space"
diff = false
overwrite = true
verbose = false
configure = [
    "AddMissingEnd:enabled=True",
]

I took 2min tried and failed to adapt it to the new robocop syntax :sweat_smile:

Abe210 avatar Sep 03 '25 09:09 Abe210