dolthub / dolthub-issues

Issues for dolthub.com
https://dolthub.com
4 stars 1 forks source link

SQL API fails with return code 404 when targeting branches with a slash in their name #499

Closed AtomicTroop closed 1 year ago

AtomicTroop commented 1 year ago

When using the DoltHub SQL API to operate on a branch with a slash in its name (like the automatically named pull request branches created by the web UI Spreadsheet Editor), URI encoding the slash should correctly let me target the branch. Instead, the request fails with error 404.

Steps to reproduce the behavior:

  1. Create a new branch with a slash in its name, (for example, by using the spreadsheet editor).
  2. Attempt to query the branch by sending a GET request to https://www.dolthub.com/api/v1alpha1/<owner>/<db>/<encoded-branch-name>/<query>
  3. Receive failed response

Tested on:

This issue should of course be device-agnostic considering it's an API issue but test device and browser was included for completeness' sake. I haven't tested if the issue also exists with the CSV API but it's worth checking.

The Database API seems to pass the branch name in the request body which probably circumvents the issue. I would assume the branch name does not need to be encoded when sent as part of the request body.

liuliu-dev commented 1 year ago

Hi, @AtomicTroop , could you show me how you encoded the branch name?

I tried this database dolthub/transparency-in-pricing using the branch spacelove/docs-coy-mink, the branch name is encoded into spacelove%2Fdocs-coy-mink. The following link seems to be working for me:

https://www.dolthub.com/api/v1alpha1/dolthub/transparency-in-pricing/spacelove%2Fdocs-coy-mink?q=show%20tables;
Screenshot 2023-09-05 at 9 33 21 AM
AtomicTroop commented 1 year ago

Hi again, thanks for the response, I went back to sanity check and indeed, while the encoded uri did work I had missed encoding one successive request further down the serverside function resulting in the 404 not found error.

So TL;DR, chalk this one up to user error. Closing this one now as everything seems to be working fine after all.