msteamsv2: inherit global proxy_url into partial http_config#5379
Conversation
Signed-off-by: Mihir Dixit <dixitmihir1@gmail.com>
📝 WalkthroughWalkthroughThe PR changes msteamsv2 HTTP config unmarshalling to copy global HTTP settings safely and to inherit only the proxy URL when a local config is partial. It also adds tests for missing, partial, and locally overridden proxy settings. ChangesMSTeamsV2 Proxy Inheritance
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
config/config_test.go (2)
1834-1867: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMissing test coverage for partial proxy sub-fields other than
proxy_url.None of the three tests exercise a receiver-level
http_configthat setsno_proxy,proxy_from_environment, orproxy_connect_headerwithoutproxy_url. As flagged inconfig/config.go(lines 599-603), the current implementation overwrites the entireProxyConfigstruct when onlyproxy_urlis missing, which would silently drop such locally-configured fields. A test covering this scenario would catch that regression.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/config_test.go` around lines 1834 - 1867, Add coverage for receiver-level partial http_config cases in TestMSTeamsV2GlobalProxyInheritedWhenPartialHTTPConfig or a new test around Load and MSTeamsV2Configs so it verifies local proxy sub-fields like no_proxy, proxy_from_environment, or proxy_connect_header are preserved when global proxy_url is inherited. The issue is that the current proxy merging path in the config loading logic overwrites ProxyConfig when proxy_url is absent; update the config merge behavior so it only fills missing proxy_url and leaves any explicitly set sub-fields intact, and validate this with assertions on rc.HTTPConfig.ProxyConfig after Load.
1803-1832: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider using
testify/requirefor assertions instead of rawif/t.Fatalf.These new tests use manual
ifchecks witht.Fatalf/t.Errorfrather thanrequire. As per coding guidelines, usegithub.com/stretchr/testify/requireinstead ofgithub.com/stretchr/testify/assertin Go tests — implying testify is the expected assertion library for tests in this repo.Also applies to: 1836-1867, 1871-1899
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/config_test.go` around lines 1803 - 1832, The new MSTeams V2 proxy inheritance tests are using manual if checks and t.Fatalf/t.Errorf instead of the repo’s preferred testify require assertions. Update TestMSTeamsV2GlobalProxyInheritedWhenNoLocalHTTPConfig and the related MSTeams V2 test functions in this block to use github.com/stretchr/testify/require for all nil/value assertions, replacing raw conditionals while keeping the same expectations and test flow.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/config.go`:
- Around line 599-603: The current fallback in the msteamsv2 HTTP config logic
overwrites the entire ProxyConfig instead of only inheriting proxy_url. Update
the conditional in the msteamsv2 HTTPConfig handling so that when
ProxyConfig.ProxyURL is nil, only the ProxyURL field is copied from
c.Global.HTTPConfig.ProxyConfig and the existing local NoProxy,
ProxyFromEnvironment, and ProxyConnectHeader values are preserved. Use the
msteamsv2.HTTPConfig.ProxyConfig and c.Global.HTTPConfig.ProxyConfig symbols to
locate the change.
---
Nitpick comments:
In `@config/config_test.go`:
- Around line 1834-1867: Add coverage for receiver-level partial http_config
cases in TestMSTeamsV2GlobalProxyInheritedWhenPartialHTTPConfig or a new test
around Load and MSTeamsV2Configs so it verifies local proxy sub-fields like
no_proxy, proxy_from_environment, or proxy_connect_header are preserved when
global proxy_url is inherited. The issue is that the current proxy merging path
in the config loading logic overwrites ProxyConfig when proxy_url is absent;
update the config merge behavior so it only fills missing proxy_url and leaves
any explicitly set sub-fields intact, and validate this with assertions on
rc.HTTPConfig.ProxyConfig after Load.
- Around line 1803-1832: The new MSTeams V2 proxy inheritance tests are using
manual if checks and t.Fatalf/t.Errorf instead of the repo’s preferred testify
require assertions. Update
TestMSTeamsV2GlobalProxyInheritedWhenNoLocalHTTPConfig and the related MSTeams
V2 test functions in this block to use github.com/stretchr/testify/require for
all nil/value assertions, replacing raw conditionals while keeping the same
expectations and test flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9bc82477-712e-42fa-ba3e-028d0a74f027
📒 Files selected for processing (2)
config/config.goconfig/config_test.go
Signed-off-by: Mihir Dixit <dixitmihir1@gmail.com>
Title:
msteamsv2: inherit global proxy_url into partial http_configFixes #5374
When a receiver's
http_configisnil, the global config is copied in as before. When a receiver has a partialhttp_configbut no proxy set, the global proxy settings are now merged in so they take effect.Which user-facing changes does this PR introduce?
Description
Fixes a bug in
msteamsv2_configswhere a receiver-levelhttp_configcontaining only partial settings (e.g.http_headers) would cause the globalproxy_urlto be silently ignored.Previously, the config wiring used
cmp.Or(msteamsv2.HTTPConfig, c.Global.HTTPConfig)which only falls back to the global config when the receiver'shttp_configis completely absent. If a user sets any field underhttp_configin the receiver, the global proxy is dropped entirely.Config that triggers the bug:
Implementation notes:
http_configisnilon the receiver, the global config is deep-copied in (same behaviour as before, but avoids shared-pointer mutation).http_configis set but has no proxy, only theProxyConfigfield is inherited from global - the rest of the receiver's config is left untouched.proxy_url, it is not overwritten.