atomashpolskiy / bt

BitTorrent library and client with DHT, magnet links, encryption and more
https://atomashpolskiy.github.io/bt/
Apache License 2.0
2.4k stars 382 forks source link

[BUG] Weird metainfo validation error in CLI #201

Open atomashpolskiy opened 2 years ago

atomashpolskiy commented 2 years ago

Describe the bug Happens in CLI, then it just hangs (does not terminate).

[16/Dec/2021:19:49:54,073] INFO  BtRuntimeBuilder: Loading standard extension module bt.peer.lan.LocalServiceDiscoveryModule
[16/Dec/2021:19:49:54,079] INFO  BtRuntimeBuilder: Loading standard extension module bt.peerexchange.PeerExchangeModule
[16/Dec/2021:19:49:54,080] INFO  BtRuntimeBuilder: Overriding auto-loaded module bt.dht.DHTModule
[16/Dec/2021:19:49:54,081] INFO  BtRuntimeBuilder: Auto-loading module bt.portmapping.upnp.UpnpPortMapperModule with default configuration
[16/Dec/2021:19:49:54,081] INFO  BtRuntimeBuilder: Auto-loading module bt.tracker.http.HttpTrackerModule with default configuration
[16/Dec/2021:19:49:54,784] INFO  PortMappingInitializer: Mapping application's acceptor port on startup.
[16/Dec/2021:19:49:55,022] INFO  SocketChannelConnectionAcceptor: Opening server channel for incoming connections @ /192.168.1.134:6891
[16/Dec/2021:19:49:55,268] ERROR TerminateOnErrorProcessingStage: Unexpected error during processing, will finalize context and terminate...
bt.BtException: Validation failed for torrent metainfo:
1. Standard torrent model: [Wrong type -- expected java.lang.Number, actual: [B]
2. Standalone info dictionary model: [properties are mutually exclusive: [[length], [files]]; properties are required: [length, files]; properties are required: [piece length, pieces]]
        at bt.metainfo.MetadataService.buildTorrent(MetadataService.java:110)
        at bt.metainfo.MetadataService.fromUrl(MetadataService.java:74)
        at bt.TorrentClientBuilder.fetchTorrentFromUrl(TorrentClientBuilder.java:340)
        at bt.TorrentClientBuilder.lambda$buildProcessingContext$0(TorrentClientBuilder.java:273)
        at bt.processor.torrent.FetchTorrentStage.doExecute(FetchTorrentStage.java:36)
        at bt.processor.torrent.FetchTorrentStage.doExecute(FetchTorrentStage.java:25)
        at bt.processor.TerminateOnErrorProcessingStage.doExecute(TerminateOnErrorProcessingStage.java:38)
        at bt.processor.RoutingProcessingStage.execute(RoutingProcessingStage.java:39)
        at bt.processor.ChainProcessor.doExecute(ChainProcessor.java:112)
        at bt.processor.ChainProcessor.executeStage(ChainProcessor.java:96)
        at bt.processor.ChainProcessor.lambda$process$0(ChainProcessor.java:81)
        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
[16/Dec/2021:19:49:55,376] WARN  PortMappingListener: Failed to add port mapping: (PortMapping) Protocol: UDP, 49001 => /192.168.1.134
[16/Dec/2021:19:49:55,377] WARN  PortMappingListener: Reason: Error: Argument Value Invalid (HTTP response was: 500 Internal Server Error)
[16/Dec/2021:19:49:55,796] WARN  PortMappingListener: Failed to add port mapping: (PortMapping) Protocol: TCP, 6891 => /192.168.1.134
[16/Dec/2021:19:49:55,797] WARN  PortMappingListener: Reason: Error: Argument Value Invalid (HTTP response was: 500 Internal Server Error)

To Reproduce Can't post the link to .torrent here.

pvishnyakov commented 9 months ago

Got the same error, have you found the cause? Another library is parsing the same torrent file without any problem so it's not a file issue.

pyckle commented 9 months ago

This sounds like a corrupted torrent file. More specifically from http://bittorrent.org/beps/bep_0003.html

There is also a key length or a key files, but not both or neither. If length is present then the download represents a single file, otherwise it represents a set of files which go in a directory structure.

pvishnyakov commented 7 months ago

I would consider the file corrupted but jlibtorrent is handling the same file without any issue