Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR Can not unmarshal JSON for preferences #34

Closed
peterpiglet opened this issue Mar 12, 2024 · 22 comments
Closed

ERROR Can not unmarshal JSON for preferences #34

peterpiglet opened this issue Mar 12, 2024 · 22 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@peterpiglet
Copy link

Hi, I was using the exporter without problems using qbit 4.5.2 and 4.6.2. However, I just downgraded a client to 4.3.9 and the exporter does not work with this client.

With qbit 4.3.9 I just see the following error in the logs:

Screenshot 2024-03-12 182102

Is there anything I can do to make it work with 4.3.9?

@martabal
Copy link
Owner

Hello !
qbit 4.3.9 is pretty old, there is a very good chance that the api is incompatible. I can try to support it, can you share the API response for : http://your-url:port/api/v2/app/preferences ?

@peterpiglet
Copy link
Author

Hey, that would be great. Thanks for looking into it.

Here is the API response:

{"add_trackers":"","add_trackers_enabled":false,"alt_dl_limit":10240,"alt_up_limit":10240,"alternative_webui_enabled":false,"alternative_webui_path":"","announce_ip":"","announce_to_all_tiers":true,"announce_to_all_trackers":false,"anonymous_mode":false,"async_io_threads":10,"auto_delete_mode":0,"auto_tmm_enabled":true,"autorun_enabled":true,"autorun_program":"","banned_IPs":"","bittorrent_protocol":1,"block_peers_on_privileged_ports":false,"bypass_auth_subnet_whitelist":"###.###.###.#/##","bypass_auth_subnet_whitelist_enabled":true,"bypass_local_auth":false,"category_changed_tmm_enabled":true,"checking_memory_use":32,"current_interface_address":"","current_network_interface":"tun0","dht":false,"disk_cache":-1,"disk_cache_ttl":60,"dl_limit":0,"dont_count_slow_torrents":false,"dyndns_domain":"changeme.dyndns.org","dyndns_enabled":false,"dyndns_password":"","dyndns_service":0,"dyndns_username":"","embedded_tracker_port":####,"enable_coalesce_read_write":false,"enable_embedded_tracker":false,"enable_multi_connections_from_same_ip":false,"enable_os_cache":true,"enable_piece_extent_affinity":false,"enable_upload_suggestions":false,"encryption":0,"export_dir":"","export_dir_fin":"","file_pool_size":5000,"hashing_threads":2,"idn_support_enabled":false,"incomplete_files_ext":false,"ip_filter_enabled":false,"ip_filter_path":"","ip_filter_trackers":false,"limit_lan_peers":false,"limit_tcp_overhead":false,"limit_utp_rate":false,"listen_port":#####,"locale":"en","lsd":false,"mail_notification_auth_enabled":true,"mail_notification_email":"","mail_notification_enabled":false,"mail_notification_password":"","mail_notification_sender":"","mail_notification_smtp":"smtp.changeme.com","mail_notification_ssl_enabled":false,"mail_notification_username":"","max_active_downloads":3,"max_active_torrents":5,"max_active_uploads":3,"max_concurrent_http_announces":50,"max_connec":500,"max_connec_per_torrent":100,"max_ratio":-1,"max_ratio_act":0,"max_ratio_enabled":false,"max_seeding_time":-1,"max_seeding_time_enabled":false,"max_uploads":20,"max_uploads_per_torrent":4,"outgoing_ports_max":0,"outgoing_ports_min":0,"peer_tos":32,"peer_turnover":4,"peer_turnover_cutoff":90,"peer_turnover_interval":300,"pex":false,"preallocate_all":false,"proxy_auth_enabled":false,"proxy_ip":"0.0.0.0","proxy_password":"","proxy_peer_connections":false,"proxy_port":8080,"proxy_torrents_only":false,"proxy_type":0,"proxy_username":"","queueing_enabled":false,"random_port":false,"recheck_completed_torrents":false,"resolve_peer_countries":true,"rss_auto_downloading_enabled":false,"rss_download_repack_proper_episodes":false,"rss_max_articles_per_feed":50,"rss_processing_enabled":false,"rss_refresh_interval":30,"rss_smart_episode_filters":"s(\\d )e(\\d )\n(\\d )x(\\d )\n(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})\n(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})","save_path":"/downloads/","save_path_changed_tmm_enabled":true,"save_resume_data_interval":60,"scan_dirs":{},"schedule_from_hour":8,"schedule_from_min":0,"schedule_to_hour":20,"schedule_to_min":0,"scheduler_days":0,"scheduler_enabled":false,"send_buffer_low_watermark":10,"send_buffer_watermark":500,"send_buffer_watermark_factor":50,"slow_torrent_dl_rate_threshold":2,"slow_torrent_inactive_timer":60,"slow_torrent_ul_rate_threshold":2,"socket_backlog_size":30,"ssrf_mitigation":true,"start_paused_enabled":false,"stop_tracker_timeout":5,"temp_path":"/downloads/incomplete/","temp_path_enabled":false,"torrent_changed_tmm_enabled":true,"torrent_content_layout":"Original","up_limit":0,"upload_choking_algorithm":1,"upload_slots_behavior":0,"upnp":false,"upnp_lease_duration":0,"use_https":false,"utp_tcp_mixed_mode":0,"validate_https_tracker_certificate":true,"web_ui_address":"*","web_ui_ban_duration":3600,"web_ui_clickjacking_protection_enabled":false,"web_ui_csrf_protection_enabled":false,"web_ui_custom_http_headers":"","web_ui_domain_list":"*","web_ui_host_header_validation_enabled":false,"web_ui_https_cert_path":"","web_ui_https_key_path":"","web_ui_max_auth_fail_count":5,"web_ui_port":#####,"web_ui_secure_cookie_enabled":true,"web_ui_session_timeout":3600,"web_ui_upnp":false,"web_ui_use_custom_http_headers_enabled":false,"web_ui_username":"###"}

@martabal
Copy link
Owner

Mmmh, that API endpoint is not the issue, the log message was wrong, I fixed it with #35. Can you re-try with docker tag pr-35 please ?

@peterpiglet
Copy link
Author

just pulled pr-35. I see the same ERROR in the logs. In prometheus I see Get "http://192.168.178.26:8090/metrics": context deadline exceeded as error messages for the target. Can I provide some other e.g. logs?

@martabal
Copy link
Owner

Mmmh, I thought the error message was going to change

@martabal
Copy link
Owner

What's the API response for http://your-url/api/v2/app/webapiVersion ?

@peterpiglet
Copy link
Author

peterpiglet commented Mar 13, 2024

Hey, the response is 2.8.2.

Which according to the qbit website is the current webAPI for all versions above 4.1.

@martabal
Copy link
Owner

Ok great, so that's not the problem. Did you edit the first API response you posted (the API response for http://your-url:port/api/v2/app/preferences) ?

@peterpiglet
Copy link
Author

peterpiglet commented Mar 13, 2024

Yes, I edited some entries to anonymize it e.g. ports, username. I exchange the charaters with # (e.g. "web_ui_username":"###"). I did not change the structure or remove entries. Sorry, should have told you that.

@martabal
Copy link
Owner

martabal commented Mar 13, 2024

Yes, that's what I thought, but #is not a valid character in JSON so this is is why I ask.
I added more logs, can you re-try ? (don't forget to re-pull the image and add / set LOG_LEVEL to DEBUG)

@peterpiglet
Copy link
Author

OK, I have:

  1. stopped and removed the container
  2. deleted the image
  3. added LOG_LEVEL=DEBUG to my compose under environment variables
  4. repulled the image pr-35 and recreated the container

The outcome is somewhat the same with an extra DEBUG line in the logs:

Screenshot 2024-03-13 113627

@martabal
Copy link
Owner

Sorry, small issue with the CD, it should be fixed now, you can re-pull the image

@peterpiglet
Copy link
Author

Sure, no problem. Now the logs became more verbose:

[13/03/2024 11:11:39] DEBUG New request
[13/03/2024 11:11:40] ERROR Can not unmarshal JSON for tracker
[13/03/2024 11:11:40] DEBUG json: cannot unmarshal string into Go struct field .tier of type int

@martabal
Copy link
Owner

Oh interesting, what's the API response for http://your-url/api/v2/torrents/trackers?hash=<torrent-hash>

@peterpiglet
Copy link
Author

OK, so if understood correctly I change <torrent-hash> to the hash of one random torrent in my client to got the API response (I anonymized the url entry with ###):

[{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":"** [DHT] "},{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":" [PeX] "},{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":" [LSD] **"},{"msg":"","num_downloaded":-1,"num_leeches":-1,"num_peers":14,"num_seeds":-1,"status":2,"tier":0,"url":"###"}]

I also stumbled upon this entry in the API changelog LINK. I don't know if its of interest, just stated change string to integer, which reminded me of the DEBUG error with something about int. I am a noob, so ignore my comments if they do not help :D

Change status field from translated string to an integer for /torrents/trackers (#9375)

@martabal
Copy link
Owner

I added more logs, you can re-pull the image

@peterpiglet
Copy link
Author

Yes, here is the new log (I anonymized the url entry with ###):

[13/03/2024 11:59:39] DEBUG New request
[13/03/2024 11:59:40] ERROR Can not unmarshal JSON for tracker
[13/03/2024 11:59:40] DEBUG [{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":"** [DHT] "},{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":" [PeX] "},{"msg":"This torrent is private","num_downloaded":0,"num_leeches":0,"num_peers":0,"num_seeds":0,"status":0,"tier":"","url":" [LSD] **"},{"msg":"","num_downloaded":190,"num_leeches":0,"num_peers":14,"num_seeds":14,"status":2,"tier":0,"url":"###"}]
[13/03/2024 11:59:40] DEBUG json: cannot unmarshal string into Go struct field .tier of type int

@martabal
Copy link
Owner

Ok, I see what's the issue, I'll correct it this evening. Thank you for your reactivity !

@peterpiglet
Copy link
Author

@martabal thank you for the support!

@martabal
Copy link
Owner

To explain what's going on : The qBittorrent API had an issue where it sent an empty string instead of an integer which causes this error (qbittorrent/qBittorrent#15545 and qbittorrent/qBittorrent#13302).

I fixed it, it should work again, @peterpiglet can you confirm it 😄 ? (you have to pull again pr-35 image)

@peterpiglet
Copy link
Author

Awesome! I can confirm, it is working again. And consequently my Grafana dashboard is working too. satisfaction 😄

Thank you very much for the support!

@martabal
Copy link
Owner

Nice !

I released v1.2.0 with the fix, so you can revert to the latest tag.
Thank you again for your responsiveness, you helped a lot to understand what was wrong !

@martabal martabal added bug Something isn't working enhancement New feature or request labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants