PathOfBuilding icon indicating copy to clipboard operation
PathOfBuilding copied to clipboard

Header parsing in TradeQueryRateLimiterClass (Error calling OnSubFinished: 2)

Open Turmfalke2 opened this issue 3 years ago • 0 comments

hi, First of all my setup is a bit unusual, in that I run pob natively on Linux with an alternate frontend, but I hope my report still has value.

I wanted to use the new trade search feature, but it would always print the following error and be stuck searching forever.

Error calling OnSubFinished: 2
error in error handling

A million print statements later I tracked down the error to be an issue with parsing http headers in TradeQueryRateLimiterClass:ParsePolicy when called to update the rate limit after the first request. The main issue here is that my libcurl appears to output the headers differently to that of the code's author.

Example:

access-control-expose-headers:X-Rate-Limit-Policy, X-Rate-Limit-Rules, X-Rate-Limit-Account, X-Rate-Limit-Account-State, X-Rate-Limit-Ip, X-Rate-Limit-Ip-State
x-rate-limit-policy:trade-search-request-limit
x-rate-limit-rules:Account,Ip
x-rate-limit-account:3:5:60
x-rate-limit-account-state:1:5:0
x-rate-limit-ip:8:10:60,15:60:120,60:300:1800
x-rate-limit-ip-state:1:10:0,1:60:0,3:300:0

Note that the headers themself here are all lowercase, but values for x-rate-limit-rules are not. With

Field names are case-insensitive and ought to be registered within the "Hypertext Transfer Protocol (HTTP) Field Name Registry"; see Section 16.3.1. https://www.rfc-editor.org/rfc/rfc9110.html#section-5.1

in mind I would suggest casting k in TradeQueryRateLimiterClass:ParseHeader and match within the TradeQueryRateLimiterClass:ParsePolicy to lower case. In addition to that fixed header access calls should then also be lower case.

0001-fix-http-header-parsing.patch.txt

Turmfalke2 avatar Dec 13 '22 16:12 Turmfalke2