Skip to content

fix(connection): template HTTP connection fields - #2005

Merged
adityathebe merged 1 commit into
mainfrom
fix/http-connection-templating
Jun 12, 2026
Merged

fix(connection): template HTTP connection fields#2005
adityathebe merged 1 commit into
mainfrom
fix/http-connection-templating

Conversation

@adityathebe

@adityathebe adityathebe commented Jun 12, 2026

Copy link
Copy Markdown
Member

related: flanksource/mission-control#3218

HTTP playbook actions can template the action itself, but embedded HTTP connection fields were skipped unless the fields also carried template tags.

This left values like $(.params.url) unresolved, causing HTTP requests to run against literal relative URLs such as /$(.params.url).

Add template tags across HTTP connection, auth, OAuth, TLS, and AWS SigV4 fields so existing playbook templating handles connection configuration correctly.

Summary by CodeRabbit

  • New Features
    • AWS connections now support dynamic values in connection names, credentials, region, and endpoint settings.
    • HTTP connections now support dynamic values in URLs, headers, bearer tokens, and OAuth credentials.
    • Authentication credentials and OAuth configuration now support dynamic variable injection across all connection types.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Benchstat (Other)

Base: 3e29f6c6428877992152f66847e5925d69bcb77c
Head: e034a118f3e52895338a25086c47ffb5f15e1764

📊 1 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
ResourceSelectorQueryBuild/tags-4 17.59µ 17.75µ +0.91% 0.002
✅ 2 improvement(s)
Benchmark Base Head Change p-value
ResourceSelectorQueryBuild/name_and_type-4 64.55µ 64.00µ -0.86% 0.009
ResourceSelectorQueryBuild/name-4 44.23µ 43.97µ -0.58% 0.009
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                                       │ bench-base.txt │           bench-head.txt           │
                                                       │     sec/op     │    sec/op     vs base              │
InsertionForRowsWithAliases/external_users.aliases-4       602.7µ ± 11%   600.4µ ±  6%       ~ (p=0.485 n=6)
InsertionForRowsWithAliases/config_items.external_id-4     1.108m ± 11%   1.097m ± 12%       ~ (p=0.589 n=6)
InsertionOfConfigsWithProperties-4                         3.797m ±  2%   3.760m ±  2%       ~ (p=0.394 n=6)
UpdateOfConfigsWithProperties-4                            7.495m ±  1%   7.518m ±  1%       ~ (p=0.394 n=6)
ResourceSelectorConfigs/name-4                             222.5µ ±  2%   222.6µ ±  3%       ~ (p=1.000 n=6)
ResourceSelectorConfigs/name_and_type-4                    239.5µ ±  3%   239.7µ ±  4%       ~ (p=0.589 n=6)
ResourceSelectorConfigs/tags-4                             30.48m ±  3%   30.31m ±  3%       ~ (p=0.699 n=6)
ResourceSelectorQueryBuild/name-4                          44.23µ ±  2%   43.97µ ±  1%  -0.58% (p=0.009 n=6)
ResourceSelectorQueryBuild/name_and_type-4                 64.55µ ±  4%   64.00µ ±  0%  -0.86% (p=0.009 n=6)
ResourceSelectorQueryBuild/tags-4                          17.59µ ±  1%   17.75µ ±  0%  +0.91% (p=0.002 n=6)
geomean                                                    523.7µ         522.1µ        -0.30%

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Benchstat (RLS)

Base: 3e29f6c6428877992152f66847e5925d69bcb77c
Head: e034a118f3e52895338a25086c47ffb5f15e1764

📊 2 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
RLS/Sample-15000/config_classes/With_RLS-4 118.1m 120.9m +2.43% 0.002
RLS/Sample-15000/config_types/With_RLS-4 120.8m 121.5m +0.61% 0.002
✅ 5 improvement(s)
Benchmark Base Head Change p-value
RLS/Sample-15000/configs/Without_RLS-4 7.332m 7.142m -2.59% 0.002
RLS/Sample-15000/catalog_changes/Without_RLS-4 4.500m 4.408m -2.06% 0.009
RLS/Sample-15000/config_summary/Without_RLS-4 92.62m 90.91m -1.85% 0.002
RLS/Sample-15000/config_changes/Without_RLS-4 4.467m 4.392m -1.68% 0.002
RLS/Sample-15000/config_detail/With_RLS-4 120.7m 120.3m -0.36% 0.015
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 9V74 80-Core Processor                
                                               │ bench-base.txt │          bench-head.txt           │
                                               │     sec/op     │   sec/op     vs base              │
RLS/Sample-15000/catalog_changes/Without_RLS-4      4.500m ± 6%   4.408m ± 1%  -2.06% (p=0.009 n=6)
RLS/Sample-15000/catalog_changes/With_RLS-4         125.8m ± 2%   125.2m ± 5%       ~ (p=0.485 n=6)
RLS/Sample-15000/config_changes/Without_RLS-4       4.467m ± 1%   4.392m ± 1%  -1.68% (p=0.002 n=6)
RLS/Sample-15000/config_changes/With_RLS-4          125.3m ± 1%   124.8m ± 1%       ~ (p=0.132 n=6)
RLS/Sample-15000/config_detail/Without_RLS-4        4.255m ± 1%   4.235m ± 1%       ~ (p=0.240 n=6)
RLS/Sample-15000/config_detail/With_RLS-4           120.7m ± 1%   120.3m ± 0%  -0.36% (p=0.015 n=6)
RLS/Sample-15000/config_names/Without_RLS-4         12.51m ± 3%   12.78m ± 1%       ~ (p=0.065 n=6)
RLS/Sample-15000/config_names/With_RLS-4            121.2m ± 0%   121.0m ± 1%       ~ (p=0.589 n=6)
RLS/Sample-15000/config_summary/Without_RLS-4       92.62m ± 2%   90.91m ± 1%  -1.85% (p=0.002 n=6)
RLS/Sample-15000/config_summary/With_RLS-4          608.8m ± 2%   607.8m ± 1%       ~ (p=0.394 n=6)
RLS/Sample-15000/configs/Without_RLS-4              7.332m ± 4%   7.142m ± 0%  -2.59% (p=0.002 n=6)
RLS/Sample-15000/configs/With_RLS-4                 121.1m ± 1%   121.1m ± 1%       ~ (p=1.000 n=6)
RLS/Sample-15000/analysis_types/Without_RLS-4       3.390m ± 0%   3.373m ± 3%       ~ (p=1.000 n=6)
RLS/Sample-15000/analysis_types/With_RLS-4          3.394m ± 3%   3.402m ± 1%       ~ (p=0.485 n=6)
RLS/Sample-15000/analyzer_types/Without_RLS-4       3.231m ± 2%   3.224m ± 1%       ~ (p=0.180 n=6)
RLS/Sample-15000/analyzer_types/With_RLS-4          3.229m ± 3%   3.234m ± 1%       ~ (p=0.853 n=6)
RLS/Sample-15000/change_types/Without_RLS-4         4.410m ± 2%   4.406m ± 1%       ~ (p=0.485 n=6)
RLS/Sample-15000/change_types/With_RLS-4            4.445m ± 1%   4.490m ± 2%       ~ (p=0.093 n=6)
RLS/Sample-15000/config_classes/Without_RLS-4       3.588m ± 2%   3.551m ± 1%       ~ (p=0.093 n=6)
RLS/Sample-15000/config_classes/With_RLS-4          118.1m ± 0%   120.9m ± 9%  +2.43% (p=0.002 n=6)
RLS/Sample-15000/config_types/Without_RLS-4         4.277m ± 1%   4.253m ± 4%       ~ (p=0.394 n=6)
RLS/Sample-15000/config_types/With_RLS-4            120.8m ± 0%   121.5m ± 1%  +0.61% (p=0.002 n=6)
geomean                                             18.36m        18.31m       -0.28%

HTTP playbook actions template the action spec, but embedded HTTP connection fields were skipped unless the nested fields carried template tags. Values such as $(.params.url) could remain unresolved and be treated as literal relative URLs during request execution.

Add template tags across HTTP connection, auth, OAuth, TLS, and AWS SigV4 fields so existing struct templating renders connection configuration before use.
@adityathebe
adityathebe force-pushed the fix/http-connection-templating branch from 84efe19 to e034a11 Compare June 12, 2026 08:31
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds template:"true" struct tags to credential, authentication, and HTTP connection type fields across five files. Core types (AWS, basic auth, OAuth) are updated first, followed by HTTP connection compositions that use them, with a new test validating HTTPConnection template field hydration.

Changes

Template support for credential and connection types

Layer / File(s) Summary
Core credential and auth types with template support
connection/aws.go, types/auth.go, types/oauth.go
AWSConnection, HTTPBasicAuth, Authentication, and OAuth add template:"true" struct tags to credential and auth fields (ConnectionName, AccessKey, SecretKey, SessionToken, Username, Password, ClientID, ClientSecret, Scopes, TokenURL, Params), enabling template variable substitution.
HTTP connection types with template support
connection/http.go
TLSConfig, AWSSigV4, and HTTPConnection add template:"true" tags to their own fields and embedded credential/auth types, composing the core types for use in HTTP connection configurations.
HTTPConnection template field validation test
connection/http_test.go
New TestHTTPConnectionTemplatesFields test imports duty context utilities and verifies that HTTPConnection fields—including connection name, basic auth, bearer, OAuth (with scopes and params), TLS, headers, and AWS SigV4—correctly hydrate templated values via ctx.NewStructTemplater(...).Walk().
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(connection): template HTTP connection fields' directly and accurately summarizes the main change: adding template tags to HTTP connection fields to enable proper templating of nested auth, OAuth, TLS, and AWS SigV4 configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/http-connection-templating
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/http-connection-templating

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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 `@connection/http.go`:
- Line 104: The HTTPConnection struct currently inlines types.HTTPBasicAuth only
for JSON; update the struct tag for types.HTTPBasicAuth (the embedded type) to
include yaml:",inline" as well (e.g., add yaml:",inline" alongside
json:",inline") so YAML top-level auth fields map correctly; locate the
embedding of types.HTTPBasicAuth inside the HTTPConnection definition and modify
its struct tag accordingly.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 498964d5-3c2f-43da-8cf9-e97728698c79

📥 Commits

Reviewing files that changed from the base of the PR and between 3e29f6c and e034a11.

📒 Files selected for processing (5)
  • connection/aws.go
  • connection/http.go
  • connection/http_test.go
  • types/auth.go
  • types/oauth.go

Comment thread connection/http.go
@adityathebe
adityathebe merged commit 2b3d1cf into main Jun 12, 2026
18 of 19 checks passed
@adityathebe
adityathebe deleted the fix/http-connection-templating branch June 12, 2026 08:36
@adityathebe
adityathebe requested a review from moshloop June 12, 2026 08:36
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Gavel results

Gavel exited with code .

View full results

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant