mirror of
https://github.com/chatwoot/chatwoot.git
synced 2026-06-13 21:01:16 +08:00
The SafeFetch spec suite was failing in CI with `NameError: uninitialized constant SafeFetch::Fetcher` across every example that exercised `SafeFetch.fetch`. From a product perspective, this made the external-file fetch path look unreliable even though the failure happened before any network validation, SSRF protection, content-type checks, or tempfile handling could run. The symptom pointed to a load-order issue rather than an actual fetch behavior regression. `SafeFetch.fetch` referenced `Fetcher` from the top-level module, but that nested class was not guaranteed to be loaded in every test execution path before the method was invoked. This change keeps the existing SafeFetch split between the public API and the implementation classes, but makes the public entry point responsible for loading the implementation it needs before use. That is intentionally smaller than folding all of the fetcher logic into `lib/safe_fetch.rb`; the separate files still keep the request option parsing and streaming implementation readable, while the public API no longer depends on Rails or the test runner having loaded nested constants in a particular order. The file also now uses a single `SafeFetch` module declaration. That removes the awkward reopen pattern and makes the dependency boundary easier to see: constants and errors are defined first, then the public `fetch` method loads and delegates to the implementation classes. |
||
|---|---|---|
| .. | ||
| action_view/template/handlers | ||
| assets | ||
| captain | ||
| custom_exceptions | ||
| events | ||
| filters | ||
| integrations | ||
| linear | ||
| llm | ||
| redis | ||
| safe_fetch | ||
| seeders | ||
| tasks | ||
| test_data | ||
| webhooks | ||
| base_markdown_renderer.rb | ||
| chatwoot_app.rb | ||
| chatwoot_captcha.rb | ||
| chatwoot_exception_tracker.rb | ||
| chatwoot_hub.rb | ||
| chatwoot_markdown_renderer.rb | ||
| config_loader.rb | ||
| current.rb | ||
| custom_markdown_renderer.rb | ||
| dyte.rb | ||
| exception_list.rb | ||
| global_config_service.rb | ||
| global_config.rb | ||
| limits.rb | ||
| linear.rb | ||
| llm_constants.rb | ||
| microsoft_graph_auth.rb | ||
| online_status_tracker.rb | ||
| opentelemetry_config.rb | ||
| regex_helper.rb | ||
| safe_fetch.rb | ||
| test_data.rb | ||
| url_helper.rb | ||
| vapid_service.rb | ||