langfield / ki

version control for Anki collections
https://langfield.github.io/ki/
GNU Affero General Public License v3.0
70 stars 3 forks source link

AssertionError in whatthepatch when parsing a binary diff #127

Closed abbradar closed 1 year ago

abbradar commented 1 year ago

I have encountered an issue when pulling changes from Anki:

Traceback (most recent call last):
  File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/bin/.ki-wrapped", line 9, in <module>
    sys.exit(ki())
  File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "<@beartype(ki.pull) at 0x7f8b4e4ee200>", line 11, in pull
  File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/__init__.py", line 1695, in pull
    _pull(kirepo)
  File "<@beartype(ki._pull) at 0x7f8b4e4ee170>", line 33, in _pull
  File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/__init__.py", line 1768, in _pull
    patches: Iterable[Patch] = get_patches(unsub_repo)
  File "<@beartype(ki.get_patches) at 0x7f8b4e4ed240>", line 33, in get_patches
  File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/__init__.py", line 1392, in get_patches
    for diff in whatthepatch.parse_patch(raw_unified_patch):
  File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 102, in parse_patch
    d = parse_diff(diff)
  File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 199, in parse_diff
    return parser(lines)
  File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 995, in parse_git_binary_diff
    assert len(line) >= 7 and ((len(line) - 2) % 5) != 0
AssertionError

I have dumped the raw git diff and indeed, it's a binary diff on which the error is reproducible. I plan to also submit a bug report to whatthepatch repo.

Have someone encountered this, maybe there is a known workaround? On a sidenote, this project seems being rewritten in Haskell right now, so the Python version is not actively maintained — is that right?

langfield commented 1 year ago

On the contrary, I am happy to fix bugs for you! Let me look into this. If you haven't heard back from me for a couple days, ping me again!


From: Nikolay Amiantov @.> Sent: Tuesday, April 25, 2023 3:15:28 PM To: langfield/ki @.> Cc: Subscribed @.***> Subject: [langfield/ki] AssertionError in whatthepatch when parsing a binary diff (Issue #127)

I have encountered an issue when pulling changes from Anki: Traceback (most recent call last): File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3. 10-ki-unstable-git-2023-01-25/bin/. ki-wrapped", line 9, in sys. exit(ki())

I have encountered an issue when pulling changes from Anki:

Traceback (most recent call last): File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/bin/.ki-wrapped", line 9, in sys.exit(ki()) File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/nix/store/c424f8r8i3n7zyd11vzg59yw0d5xf0vn-python3.10-click-8.1.3/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File **@.(ki.pull) at 0x7f8b4e4ee200>", line 11, in pull File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/init.py", line 1695, in pull _pull(kirepo) File @.(ki._pull) at 0x7f8b4e4ee170>", line 33, in _pull File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/init.py", line 1768, in _pull patches: Iterable[Patch] = get_patches(unsub_repo) File @.***(ki.get_patches) at 0x7f8b4e4ed240>", line 33, in get_patches File "/nix/store/6fhnx3gzcns4h41m9v73nxknrgdhd6l4-python3.10-ki-unstable-git-2023-01-25/lib/python3.10/site-packages/ki/init.py", line 1392, in get_patches for diff in whatthepatch.parse_patch(raw_unified_patch): File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 102, in parse_patch d = parse_diff(diff) File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 199, in parse_diff return parser(lines) File "/nix/store/6qz1fvnb18gzydhm8awy94lrxb0sy2y5-python3.10-whatthepatch-1.0.4/lib/python3.10/site-packages/whatthepatch/patch.py", line 995, in parse_git_binary_diff assert len(line) >= 7 and ((len(line) - 2) % 5) != 0 AssertionError

I have dumped the raw git diff and indeed, it's a binary diff on which the error is reproducible. I plan to also submit a bug report to whatthepatch repo.

Have someone encountered this, maybe there is a known workaround? On a sidenote, this project seems being rewritten in Haskell right now, so the Python version is not actively maintained — is that right?

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/127__;!!KGKeukY!zUoKpttl4Vf8HBAVgcb7ZZNcWtSmZfBts9PvgqQYef1XRtnWf0txH_3DYA8A6OBZ6I-k6irQts7jDfSm_wXODOejwdf35g$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI3WWV3VVJT3C7TOZWTXDAPFBANCNFSM6AAAAAAXLNWFCA__;!!KGKeukY!zUoKpttl4Vf8HBAVgcb7ZZNcWtSmZfBts9PvgqQYef1XRtnWf0txH_3DYA8A6OBZ6I-k6irQts7jDfSm_wXODOebqC00CA$. You are receiving this because you are subscribed to this thread.Message ID: @.***>

langfield commented 1 year ago

Ah, I see you've posted the binary diff in your issue for whatthepatch, great! I'll get right on it.

Re: the Haskell rewrite. I'm working on it. I've got 1 of 3 ops implemented, but currently I think it's still a bit clunky. I am going to try and golf the code a bit, test the clone op well, and then move on to pull and push. Slow and steady.

abbradar commented 1 year ago

Thank you for the reply! :) Someone has already tackled the issue.

No rush with the rewrite, I know it takes time.

langfield commented 1 year ago

I'm actually unable to reproduce this on whatthepatch==1.0.2, and I can't get their test to fail in the expected way either. Can you give a MWE?

abbradar commented 1 year ago

Ohh, that's my mistake -- I have removed the upper bounds on the required packages to get it to build with the Python packages from NixOS, and forgot it later. My warranty is null and void, I know!

Let me try the same thing with an older whatthepatch release. And would you mind if I try to build Ki with Poetry and send a PR for that? This would allow Nix to build it with precisely the package versions that you specify — Nix requires a lockfile with a checksum for every dependency for that.

langfield commented 1 year ago

No worries!

Unfortunately, I think I will not be adding a dependency on poetry.


From: Nikolay Amiantov @.> Sent: Wednesday, April 26, 2023 10:07:39 AM To: langfield/ki @.> Cc: langfield @.>; Comment @.> Subject: Re: [langfield/ki] AssertionError in whatthepatch when parsing a binary diff (Issue #127)

Ohh, that's my mistake -- I have removed the upper bounds on the required packages to get it to build with the Python packages from NixOS, and forgot it later. My warranty is null and void, I know! Let me try the same thing with an older whatthepatch

Ohh, that's my mistake -- I have removed the upper bounds on the required packages to get it to build with the Python packages from NixOS, and forgot it later. My warranty is null and void, I know!

Let me try the same thing with an older whatthepatch release. And would you mind if I try to build Ki with Poetryhttps://urldefense.com/v3/__https://python-poetry.org/__;!!KGKeukY!3Fn1Vw8P9KEpGaZl8l80BH0BtDB5IIC7SY9an5ChuueEsFTmYJTWQq9hHM2jy6CKXwaIESvYdGluUWvI7Z6K3dgSQ4Jlow$ and send a PR for that? This would allow Nix to build it with precisely the package versions that you specify — Nix requires a lockfile with a checksum for every dependency for that.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/127*issuecomment-1523485590__;Iw!!KGKeukY!3Fn1Vw8P9KEpGaZl8l80BH0BtDB5IIC7SY9an5ChuueEsFTmYJTWQq9hHM2jy6CKXwaIESvYdGluUWvI7Z6K3dhUgIl4uQ$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI4D7XAEGA64UO7ZK33XDET2XANCNFSM6AAAAAAXLNWFCA__;!!KGKeukY!3Fn1Vw8P9KEpGaZl8l80BH0BtDB5IIC7SY9an5ChuueEsFTmYJTWQq9hHM2jy6CKXwaIESvYdGluUWvI7Z6K3dgl33_P5Q$. You are receiving this because you commented.Message ID: @.***>