[Bug]: OpenHands crashes on non-ascii chars (π)
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
I seem to recall we recently fixed some emoji... π€ Cc: @ryanhoangt what do you think of this?
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!
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>
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?
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
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.
Keeping this open because I don't think it's resolved?
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.
This issue was closed because it has been stalled for over 30 days with no activity.