-
-
Notifications
You must be signed in to change notification settings - Fork 516
correct gc stats not coming from web server process #6743
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,13 +1,21 @@ | ||||||
| desc "Post gc stats to discord channel" | ||||||
|
|
||||||
| task post_gc_stat_to_discord: :environment do | ||||||
| stats = GC.stat | ||||||
| require "net/http" | ||||||
|
|
||||||
| url = URI("https://casavolunteertracking.org/health/gc?token=#{ENV["GC_ACCESS_TOKEN"]}") | ||||||
| response = Net::HTTP.get_response(url) | ||||||
|
|
||||||
| unless response.is_a?(Net::HTTPSuccess) | ||||||
| raise "Failed to fetch GC stats. HTTP status code:#{response.code}" | ||||||
|
||||||
| raise "Failed to fetch GC stats. HTTP status code:#{response.code}" | |
| raise "Failed to fetch GC stats. HTTP status code: #{response.code} #{response.message}. Body: #{response.body&.slice(0, 200)}" |
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stats = response.body is posted to Discord as-is. If the endpoint returns structured JSON (array/hash), consider parsing and pretty-printing it here so the Discord message is consistently readable, and so the task fails fast on invalid JSON (instead of posting an error page/HTML).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rake task hardcodes the production host and interpolates the token directly into the URL. This makes the task non-portable across environments and risks leaking the token via logs/proxies (query string) as well as incorrect encoding. Prefer deriving the base URL from configuration (e.g., an env var) and building the query via
URI.encode_www_form/URI::HTTPS.build, or sending the token in a header instead of the query string.