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

Hubble HTTP endpoint returning db error #2067

Closed
gskril opened this issue Jun 17, 2024 · 1 comment · Fixed by #2077
Closed

Hubble HTTP endpoint returning db error #2067

gskril opened this issue Jun 17, 2024 · 1 comment · Fixed by #2077
Labels
s-triage Needs to be reviewed, designed and prioritized

Comments

@gskril
Copy link
Contributor

gskril commented Jun 17, 2024

What is the bug?
Hubble's castByParent HTTP endpoint returns an error with certain url params.

How can it be reproduced?
GET https://hoyt.farcaster.xyz:2281/v1/castsByParent?url=https://warpcast.com/~/channel/page

See the response

{
  "code": 2,
  "details": "db.internal_error/could not get message with key: [1, 129, 11, 134, 0, 1, 111, 110, 101, 6, 78, 209, 172, 203, 162, 11, 104, 228, 239, 164, 151, 212, 243, 3, 81, 109, 55, 199, 100, 32]",
  "metadata": {
    "errcode": [
      null
    ]
  }
}

@github-actions github-actions bot added the s-triage Needs to be reviewed, designed and prioritized label Jun 17, 2024
Wazzymandias added a commit that referenced this issue Jun 21, 2024
## Motivation

Parameters that contained invalid cast URLs with valid cast URL prefixes
were surfacing database error instead of not found error. The url itself
did not contain parent casts, but because it contained a valid prefix,
the database lookups were returning errors.
For example, a valid URL may be:
"https://warpcast.com/~/channel/japan777iine"
An invalid URL may be: "https://warpcast.com/~/chanel-makeup"

Since both URLs contain same prefix, _part_ of the invalid param gets
processed. That "prefix" then yields an error when entries aren't found
in the database. However, no entries found is expected, because the URL
is garbage.

Instead of surfacing the database error, we now correctly surface not
found error. This should fix #2067

- Certain queries to Hub API caused db errors to surface, e.g:
```
{
  "code": 2,
  "details": "db.internal_error/could not get message with key: [1, 129, 11, 134, 0, 1, 111, 110, 101, 6, 78, 209, 172, 203, 162, 11, 104, 228, 239, 164, 151, 212, 243, 3, 81, 109, 55, 199, 100, 32]",
  "metadata": {
    "errcode": [
      null
    ]
  }
}
```

## Change Summary

**Empty URL**
```
{
  "errCode": "bad_request.invalid_param",
  "presentable": false,
  "name": "HubError",
  "code": 3,
  "details": "url < 1 byte",
  "metadata": {
    "errcode": [
      "bad_request.invalid_param"
    ]
  }
}
```

**Invalid URL**
```
{
  "errCode": "not_found",
  "presentable": false,
  "name": "HubError",
  "code": 2,
  "details": "could not get message with key: [1, 129, 11, 134, 0, 1, 111, 110, 101, 6, 78, 209, 172, 203, 162, 11, 104, 228, 239, 164, 151, 212, 243, 3, 81, 109, 55, 199, 100, 32]",
  "metadata": {
    "errcode": [
      "not_found"
    ]
  }
}
```

## Merge Checklist

_Choose all relevant options below by adding an `x` now or at any time
before submitting for review_

- [x] PR title adheres to the [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) standard
- [ ] PR has a
[changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [ ] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.
- [x] All [commits have been
signed](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#22-signing-commits)

## Additional Context

If this is a relatively large or complex change, provide more details
here that will help reviewers

<!-- start pr-codex -->

---

## PR-Codex overview
The focus of this PR is to fix the issue where the HTTP endpoint returns
"not found" instead of an internal database error.

### Detailed summary
- Fixed the issue in the `cast_store.rs` file related to generating
message primary key
- Updated error handling in `message.rs` and `store.rs` files
- Added a new function `not_found` in `store.rs`
- Modified error conversion logic in `server.ts` to handle Rust errors

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
@Wazzymandias
Copy link
Contributor

Thank you for the report. I didn't realize issues auto-resolve when PR gets merged in. This should be fixed in the next release, or if you pull and run from main branch. Feel free to re-open if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s-triage Needs to be reviewed, designed and prioritized
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants