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

fix: return better error message #2077

Merged
merged 4 commits into from
Jun 21, 2024
Merged

fix: return better error message #2077

merged 4 commits into from
Jun 21, 2024

Conversation

Wazzymandias
Copy link
Contributor

@Wazzymandias Wazzymandias commented 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

Additional Context

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


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}

@Wazzymandias Wazzymandias added the t-bug A fix for a bug with the current system label Jun 21, 2024
Copy link

vercel bot commented Jun 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hub-monorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2024 11:51pm

Copy link

changeset-bot bot commented Jun 21, 2024

🦋 Changeset detected

Latest commit: 6df47da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@farcaster/core Patch
@farcaster/hubble Patch
@farcaster/hub-nodejs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Wazzymandias Wazzymandias merged commit eacf29c into main Jun 21, 2024
8 checks passed
@Wazzymandias Wazzymandias deleted the fix/http-db-error branch June 21, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-bug A fix for a bug with the current system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hubble HTTP endpoint returning db error
2 participants