fix(forecast,twist): https base_uri so writes don't die on the http->https redirect - #164
Merged
Conversation
…https redirect Stacks::Forecast declared base_uri 'api.forecastapp.com' (no scheme), so HTTParty used http://. Forecast 301-redirects to https; GETs survive that but a redirected POST arrives malformed and Forecast returns 400. Reads worked, writes silently failed — create_assignment raised the 400 and RecurringAssignment#materialize! swallowed it (Sentry), so nothing reached Forecast and nothing surfaced in the UI. Verified live: via the class (http->301->https) POST /assignments => 400; direct https => 201. Stacks::Twist had the same scheme-less base_uri and also POSTs — fixed for the same reason. All other API clients already used https. Added a guard test pinning every HTTParty client to an https base_uri. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Stacks::Forecastdeclaredbase_uri 'api.forecastapp.com'— no scheme, so HTTParty defaulted tohttp://. Forecast 301-redirects http → https. GETs survive the redirect (reads worked), but a redirected POST arrives malformed and Forecast returns400 Bad Request. So:create_assignmentraised on the 400, andRecurringAssignment#materialize!'s per-occurrencerescue => e; Sentry.capture_exception(e)swallowed it — no occurrence recorded, no Forecast assignment, nothing in the admin UI.Verified live (against the real account)
http→ 301 →https)https://…/assignments, same body/headersThe fix
One line each:
base_uri 'https://api.forecastapp.com'and — same scheme-less pattern, also a writer —base_uri 'https://api.twist.com/api/v3'. Every other API client (Runn, Deel, Notion, Apollo) already usedhttps://.Added
test/lib/stacks/https_base_uri_test.rb— a guard that fails if any HTTParty client'sbase_uriisn'thttps://, so this silent-write-failure class can't return.Testing
Guard test fails on the old code (
got "http://api.forecastapp.com"), passes after. Fulltest/lib/stackssuite green (284 runs, 0 failures). No behavior change for reads; writes now hit https directly instead of a mangling redirect.🤖 Generated with Claude Code