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

Simplified start/end date checking in Trade Aggregations leads to Unexpected Horizon Error #398

Closed
robertDurst opened this issue Aug 6, 2019 · 0 comments · Fixed by #418
Labels

Comments

@robertDurst
Copy link
Contributor

Describe the bug
When using the tradeAggregations call I accidentally sent improperly formatted dates. In doing so I passed the SDK's check, simply checking that I included dates, however when the request gets sent to Horizon it returns 400, with a message about my offset value being incorrect (even when this is not the case):

  response:
   { type: 'https://stellar.org/horizon-errors/bad_request',
     title: 'Bad Request',
     status: 400,
     detail: 'The request you sent was invalid in some way.',
     extras:
      { invalid_field: 'offset',
        reason: 'illegal or missing offset. offset must be a multiple of an hour, less than or equal to the resolution, and less than 24 hours' } } }

What version are you on?
Lastest and greatest: ^2.2.1

To Reproduce

const foo = async () => {
  try {
    const DAY = 86400000;
    const WEEK = DAY * 7;
    const asset = new StellarSdk.Asset("DRA", "GCJKSAQECBGSLPQWAU7ME4LVQVZ6IDCNUA5NVTPPCUWZWBN5UBFMXZ53");
    let start = new Date();
    start.setDate(start.getDate() - 365);
    const end = new Date();
   
    const resp = await server
      .tradeAggregation(asset, StellarSdk.Asset.native(), start, end, WEEK, DAY)
      .call();

    return resp;
  } catch (err) {
    console.log(err);
  }
};

Expected behavior
Failure at the SDK level saying invalid date format or something along those lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant