Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

stream assumes all data as UTF-8. That's not always the case. #88

Description

@Ark-kun
resp = kubernetes.stream.stream(api.connect_get_namespaced_pod_exec, 'sleeping-bash', namespace='default', command=['bash', '-c', 'echo -n -e \\\\xD4'], stderr=True, stdin=False, stdout=True, tty=False)
site-packages\kubernetes\stream\ws_client.py in update(self, timeout)
    176            elif op_code == ABNF.OPCODE_BINARY or op_code == ABNF.OPCODE_TEXT:
    177                data = frame.data
    178                 if six.PY3:
--> 179                     data = data.decode("utf-8")
    180                 if len(data) > 1:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 1: unexpected end of data

Activity

  1. whybeyoung commented on Nov 26, 2018

    @whybeyoung

    the same error here. I solve it by change to data = data.decode("utf-8", "replace")

    but. when the file is encode by other charset, this code is not used. any other solutions?

  2. whybeyoung commented on Nov 26, 2018

    @whybeyoung

    /kind bug

  3. whybeyoung commented on Nov 26, 2018

    @whybeyoung

    /sig cluster-lifecycle

  4. roycaihw commented on Feb 4, 2019

    @roycaihw
    Member

    when the file is encode by other charset, this code is not used. any other solutions?

    from the rfc we should decode uft8 for OPCODE_TEXT but leave OPCODE_BINARY as raw. this client should not assume encoding for arbitrary binary data

  5. leavest commented on Apr 17, 2019

    @leavest

    the same error here. I solve it by change to data = data.decode("utf-8", "replace")

    but. when the file is encode by other charset, this code is not used. any other solutions?

    I get the same error when use vim command in web terminal.
    And I use this code replace.
    I haven't found any other coding errors yet

    import chardet
    data = data.decode(chardet.detect(data).get('encoding') or "utf-8")
    
  6. tbarrella commented on Jul 3, 2019

    @tbarrella

    15474ef helped to fix the error above, but it seems like this issue should be re-opened with the intent of being able to stream bytes without trying to decode them

  7. pigletfly commented on Jun 11, 2020

    @pigletfly

    /reopen

  8. k8s-ci-robot commented on Jun 11, 2020

    @k8s-ci-robot
    Contributor

    @pigletfly: You can't reopen an issue/PR unless you authored it or you are a collaborator.

    Details

    In response to this:

    /reopen

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.sig/cluster-lifecycleCategorizes an issue or PR as relevant to SIG Cluster Lifecycle.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions