Skip to content

httpoison to req - #3928

Open
kinjalh wants to merge 2 commits into
masterfrom
http-migration
Open

httpoison to req#3928
kinjalh wants to merge 2 commits into
masterfrom
http-migration

Conversation

@kinjalh

@kinjalh kinjalh commented Jul 29, 2026

Copy link
Copy Markdown
Member

use req instead of httpoison

Test Plan

Test environment: https://console.your-env.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

@kinjalh kinjalh added the backend Changes related to the backend label Jul 29, 2026
@soffi-ai

soffi-ai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Soffi AI Summary

This PR migrates the Elixir server's HTTP client layer from HTTPoison to Req across all call sites in the codebase. The motivation is to standardize on a single, modern HTTP library — Req is more idiomatic in recent Elixir, has built-in retry/decode options, and eliminates the HTTPoison dependency.

The change touches every module that previously called HTTPoison.get/post/put/delete, including: the Hydra OAuth2 client, all AI workbench integrations (GitHub, GitLab, Bitbucket, Bitbucket Datacenter, Azure DevOps), Elasticsearch and Victoria Logs providers, Prometheus and Loki clients, PR automation implementations, Helm/Kube version table fetchers, Datadog metrics provider, notification dispatcher, Ollama AI provider, and general HTTP tool helpers.

Key mechanical differences between the old and new call patterns:

  • Response structs change from %HTTPoison.Response{status_code: _, body: _} to %Req.Response{status: _, body: _}
  • Options are passed as keyword lists to Req.get/post/put/delete/1 rather than separate positional args
  • A shared helper req_opts/1 (and Console.Utils.HTTP.provider_options/2) is introduced to inject common defaults (decode_body: false, retry: false, receive_timeout) consistently
  • Azure DevOps and similar clients use Console.Utils.HTTP.provider_options/2 to map old :httpoison_*_options config keys to new :req_*_options keys for backward-compatible configuration

Commits

Commit Summary
74fb44c Initial migration of all HTTPoison call sites to Req across the Elixir server — updates response struct pattern matches (status_code → status), rewrites option passing to Req's keyword-list style, and introduces shared req_opts helpers with decode_body: false and retry: false defaults.
d9f6367 Follow-up fixes to the Req migration — corrects edge cases in response handling, aligns Azure DevOps and other clients to use Console.Utils.HTTP.provider_options/2 for config key mapping, and patches remaining HTTPoison references missed in the initial commit.

Deploy in Soffi


Updated: 2026-07-29 15:14 UTC

defp http_opts,
do:
Application.get_env(:console, :httpoison_azure_devops_options, []) ++ [recv_timeout: 60_000]
Application.get_env(:console, :req_azure_devops_options, []) ++ [receive_timeout: 60_000, decode_body: false, retry: false]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Legacy SCM options are dropped

When a deployment supplies proxy, TLS, or timeout settings through the previously supported :httpoison_*_options keys, these clients now read only the renamed :req_*_options keys, causing required connection settings to disappear and the affected SCM integrations to fail.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR migrates Console’s direct HTTP calls from HTTPoison to Req.

  • Updates response matching, request options, form encoding, redirects, and error handling across AI, deployment, SCM, metrics, log, and utility clients.
  • Adds an HTTPoison-to-Req option translation helper.
  • Reworks Victoria Metrics and AI proxy response streaming around Req’s asynchronous response API.
  • Updates affected mocks and tests to use Req response and transport-error structures.

Confidence Score: 4/5

The SCM option-key compatibility break should be fixed before merging because configured proxy and TLS settings can disappear after an upgrade.

Four workbench SCM clients stop reading their previously supported application environment keys without a fallback or translation path, causing deployment-specific HTTP settings to be silently omitted.

Files Needing Attention: lib/console/ai/tools/workbench/integration/azure_devops/client.ex, lib/console/ai/tools/workbench/integration/bitbucket/client.ex, lib/console/ai/tools/workbench/integration/bitbucket_datacenter/client.ex, lib/console/ai/tools/workbench/integration/gitlab/client.ex

Important Files Changed

Filename Overview
lib/console/utils/http.ex Adds centralized translation of legacy proxy, timeout, TLS, and redirect options into Req-compatible options.
lib/console/logs/stream/exec.ex Correctly migrates the Victoria Metrics streaming state machine to Req asynchronous responses and handles all documented message forms.
lib/console_web/controllers/ai_controller.ex Migrates the streaming AI reverse proxy to Req while filtering hop-by-hop response headers and cancelling timed-out streams.
lib/console/ai/tools/workbench/integration/azure_devops/client.ex Migrates requests to Req but drops compatibility with the existing HTTP option configuration key.
lib/console/ai/tools/workbench/integration/github/client.ex Migrates GitHub workbench requests and pagination headers to Req while translating Tentacat’s legacy request options.
lib/console/clients/prometheus/client.ex Migrates instant and range Prometheus queries to Req form encoding with equivalent connection and receive timeouts.
lib/console/clients/hydra/client.ex Migrates Hydra administration and OAuth request handling to Req without changing the decoded response contracts.

Reviews (1): Last reviewed commit: "httpoison to req" | Re-trigger Greptile

@kinjalh kinjalh added the enhancement New feature or request label Jul 29, 2026

@michaeljguarino michaeljguarino left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this generally makes sense. Have you done any e2e testing, certainly with things like elasticsearch/prometheus queries, and others that route through workbenches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Changes related to the backend enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants