Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug: undefined method `>=' for nil #1507

Closed
nikhilbadyal opened this issue Nov 30, 2024 · 1 comment · Fixed by #1515
Closed

Bug: undefined method `>=' for nil #1507

nikhilbadyal opened this issue Nov 30, 2024 · 1 comment · Fixed by #1515
Labels
🐛 Bug Something isn't working

Comments

@nikhilbadyal
Copy link
Contributor

nikhilbadyal commented Nov 30, 2024

Describe the bug
>= check on a nil object.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Self Hosting
  2. Enter Invalid Key
  3. Go to Dashboard
  4. See error

Expected behavior
Application should not crash.

What version of Maybe are you using?
"Self-hosted". Latest Commit

Screenshots / Recordings
image

Additional context
Currently the API Synth Settings screen doesn't force user to enter valid key or prevent itself from saving invalid key into DB.

image

If someone miss types a invalid API key or If somehow key becomes invalid like the key was revoked.

The usage method will return a UsageResponse object on 401.

The synth_overage tries to do .utilization >= 100 on usage. Since usage can of of type UsageResponse which doesn't have utilization. It throws an Exception.

Possible Fix -

def synth_overage?
    self.class.synth_provider&.usage&.utilization.to_i >= 100
end

and displaying a flash that key is invalid or similar.

@nikhilbadyal nikhilbadyal added the 🐛 Bug Something isn't working label Nov 30, 2024
@zachgoll
Copy link
Collaborator

zachgoll commented Dec 2, 2024

@nikhilbadyal thanks for the report. I think your proposed solution makes sense!

In the Synth settings view, we can also leverage synth_provider.healthy? to check whether the provider has a valid API key. This will return true regardless of whether the provider has an overage, so is a good use case for this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants