8000 Error message by program name too big · Issue #620 · aio-libs/aiomysql · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Error message by program name too big #620
Closed
@mrlucasrib

Description

@mrlucasrib

I'm running a python script that has a very large path, sys.argv[0] = /home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/mymonorepo/src/applications/myapp/src/server.py. This is because the application uses bazel as a monorepo manager.
But this causes aiomysql to fail to run :

  File "/home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/deps_python/pypi__aiomysql/aiomysql/connection.py", line 782, in _request_authentication
    data += struct.pack('B', len(connect_attrs)) + connect_attrs
struct.error: ubyte format requires 0 <= number <= 255
...
    raise OperationalError(2003,
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '10.5.3.133'")

This happens because it tries to create a packet to be sent over the network with 256 bytes, but the big name of the program overflows that size.

if program_name:
self._connect_attrs["program_name"] = program_name
elif sys.argv:
self._connect_attrs["program_name"] = sys.argv[0]

for k, v in self._connect_attrs.items():
k, v = k.encode('utf8'), v.encode('utf8')
connect_attrs += struct.pack('B', len(k)) + k
connect_attrs += struct.pack('B', len(v)) + v
data += struct.pack('B', len(connect_attrs)) + connect_attrs

The simplest solution would be to remove the path (or part of it) from the network packet. However, I don't know if this can cause any unexpected problems. As far as I've tested, it didn't cause any errors

I wonder if I can make a Pull Request that fixes this, leaving only the path after the last slash. Ex: from /home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/mymonorepo/src/applications/myapp/src/server.py to server.py. This would solve my problem and that of some other people I saw while researching this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0