OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: OpenHands crashes on non-ascii chars (πŸ™)

Open rex-remind101 opened this issue 8 months ago β€’ 7 comments

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

I asked OpenHands to refactor some ruby .erb code. Code in question has a frowny-face char πŸ™. OpenHands took it too seriously and sadly crashed:

RequestHTTPError: Server error β€˜500 Internal Server Error’ for url β€˜http://host.docker.internal:34274/execute_action’ For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 
Details: Traceback (most recent call last): File β€œ/openhands/code/openhands/runtime/action_execution_server.py”, line 629, in execute_action observation = await client.run_action(action) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/openhands/code/openhands/runtime/action_execution_server.py”, line 303, in run_action observation = await getattr(self, action_type)(action) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/openhands/code/openhands/runtime/action_execution_server.py”, line 477, in edit result_str, (old_content, new_content) = _execute_file_editor( ^^^^^^^^^^^^^^^^^^^^^
File β€œ/openhands/code/openhands/runtime/action_execution_server.py”, line 114, in _execute_file_editor result = editor( ^^^^^^^
File β€œ/openhands/poetry/openhands-ai-5O4_aCHf-py3.12/lib/python3.12/site-packages/openhands_aci/editor/editor.py”, line 129, in __call__ return self.insert(_path, insert_line, new_str, enable_linting) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/openhands/poetry/openhands-ai-5O4_aCHf-py3.12/lib/python3.12/site-packages/openhands_aci/editor/encoding.py”, line 113, in wrapper return method(self, path, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œ/openhands/poetry/openhands-ai-5O4_aCHf-py3.12/lib/python3.12/site-packages/openhands_aci/editor/editor.py”, line 417, in insert temp_file.write(line + β€˜\n’) File β€œ/openhands/micromamba/envs/openhands/lib/python3.12/tempfile.py”, line 499, in func_wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: β€˜ascii’ codec can’t encode character β€˜\U0001f641’ in position 39: ordinal not in range(128)

(note i added newlines to the output for readability but originally it was all in 1 single line)

looks like it's trying to encode unicode as ascii for some reason. Relevant code seems to be around here

OpenHands Installation

Docker command in README

OpenHands Version

No response

Operating System

MacOS

Logs, Errors, Screenshots, and Additional Context

No response

rex-remind101 avatar Apr 24 '25 00:04 rex-remind101

I seem to recall we recently fixed some emoji... πŸ€” Cc: @ryanhoangt what do you think of this?

enyst avatar Apr 24 '25 01:04 enyst

Yeah I think this should be fixed in https://github.com/All-Hands-AI/openhands-aci/pull/99 πŸ€” @rex-remind101 would you mind sharing the content of the .erb file that crashed the editor? That'd be helpful for me to repro this. Thanks!

ryanhoangt avatar Apr 24 '25 01:04 ryanhoangt

code is proprietary, but here's a snippet out of the 300+ line erb with some words changed

<div id="selector">
  <div class="selector redacted redacted-icons">
    <%# a big comment a big comment a big comment a big comment a big comment a big comment a big comment a big comment a big comment%>
    <% (MyClass::VALID_EMOJI - ['πŸ™']).each do |emo| %>
      <span class="<%= emo %>"><i class="<%= emo %>"></i></span>
    <% end %>
  </div>
</div>

rex-remind101 avatar Apr 25 '25 00:04 rex-remind101

Hmm this is weird, I just tested an insert using the ACI for a file with the content above and it seems to work fine... Just to make sure, what were the OpenHands version that you used when encoutering the error?

ryanhoangt avatar Apr 25 '25 06:04 ryanhoangt

looks like 0.32.0, there's a couple new versions now it looks like so i'll upgrade, but from what i can tell that's later than the pr #99 you posted

rex-remind101 avatar Apr 25 '25 16:04 rex-remind101

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 26 '25 02:05 github-actions[bot]

Keeping this open because I don't think it's resolved?

mamoodi avatar May 26 '25 13:05 mamoodi

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 26 '25 02:06 github-actions[bot]

This issue was closed because it has been stalled for over 30 days with no activity.

github-actions[bot] avatar Jul 03 '25 02:07 github-actions[bot]