Skip to content

Preserve explicit HTTP schemes in AWF API proxy targets - #58608

Merged
pelikhan merged 7 commits into
mainfrom
copilot/fix-api-target-scheme-stripping
Sep 5, 2026
Merged

Preserve explicit HTTP schemes in AWF API proxy targets#58608
pelikhan merged 7 commits into
mainfrom
copilot/fix-api-target-scheme-stripping

Conversation

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Explicit http:// engine base URLs were compiled as bare hosts, causing AWF to default to HTTPS and connect on port 443.

  • Proxy targets

    • Preserve http:// for OpenAI, Anthropic, and Gemini targets.
    • Keep HTTPS and scheme-less targets unchanged.
  • Compatibility

    • Enable scheme preservation for AWF v0.28.13+.
    • Retain bare hosts for older AWF versions, allowlists, and Copilot targets.
"targets": {
  "anthropic": {
    "host": "http://gateway.example.com"
  }
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stripping of http scheme from API targets Preserve explicit HTTP schemes in AWF API proxy targets Sep 4, 2026
Copilot AI requested a review from pelikhan September 4, 2026 21:26
@pelikhan
pelikhan marked this pull request as ready for review September 4, 2026 21:37
Copilot AI balanced review requested due to automatic review settings September 4, 2026 21:37
@pelikhan pelikhan added the awf label Sep 4, 2026

Copilot AI 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.

🟡 Changes recommended

Release metadata and exported API documentation must be updated for the new target-host behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Preserves explicit HTTP schemes in AWF API proxy targets while maintaining backward compatibility.

Changes:

  • Preserves http:// for OpenAI, Anthropic, and Gemini targets on AWF v0.28.13+.
  • Keeps older AWF versions, HTTPS, scheme-less, allowlist, and Copilot targets unchanged.
  • Adds provider and version-gating tests.
File summaries
File Description
pkg/workflow/engine_api_targets.go Adds scheme-aware proxy target extraction.
pkg/workflow/awf_feature_flags.go Adds the AWF capability gate.
pkg/workflow/awf_config_test.go Tests providers, schemes, and versions.
pkg/workflow/awf_config_build.go Uses scheme-aware targets in AWF configuration.
pkg/constants/version_constants.go Defines v0.28.13 as the minimum version.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Balanced


// extractAPIProxyTargetHost returns the target host format expected by the
// effective AWF version, preserving an explicit http:// scheme when supported.
func extractAPIProxyTargetHost(workflowData *WorkflowData, envVar string, firewallConfig *FirewallConfig) string {
Comment on lines +82 to +83
if strings.HasPrefix(workflowData.EngineConfig.Env[envVar], "http://") {
return "http://" + host
@gh-aw-bot

Copy link
Copy Markdown
Collaborator
pr-sous-chef

@copilot Please take the next forward-progress pass on this PR.

  • Copilot flagged follow-up work outside the core code path: update release metadata and exported API documentation for the new target-host behavior.
  • Please make the required metadata/docs updates, confirm the version gate remains correct, and then run the pr-finisher skill before handing back to maintainers.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 31.1 AIC · ⌖ 8.7 AIC · ⊞ 9K ·
Comment /souschef to run again

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer failed. Please review the logs for details.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Ponytail Reviewer for #58608

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-09-04T22:06:32Z
review_event: REQUEST_CHANGES
top_themes:
  - http target preservation drops explicit ports
files_reviewed:
  - pkg/constants/version_constants.go
  - pkg/workflow/awf_config_build.go
  - pkg/workflow/awf_config_test.go
  - pkg/workflow/awf_feature_flags.go
  - pkg/workflow/engine_api_targets.go
comment_count: 1

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 34.5 AIC · ⌖ 7.38 AIC · ⊞ 23.5K ·
Comment /review to run again

@github-actions github-actions 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.

REQUEST_CHANGES

The fix is headed in the right direction, but it still breaks a real class of HTTP endpoints by dropping explicit ports when rebuilding the target host.

Blocking theme

The new extractAPIProxyTargetHost path preserves (redacted) but reconstructs the target from a helper that has already normalized the URL. That means (host/redacted) turns into `(host/redacted) which silently changes the destination port and defeats the purpose of preserving explicit HTTP targets for local or internal gateways.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 34.5 AIC · ⌖ 7.38 AIC · ⊞ 23.5K
Comment /review to run again

return host
}

if strings.HasPrefix(workflowData.EngineConfig.Env[envVar], "http://") {

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.

This helper still rebuilds the target as "(redacted) + host, so any explicit non-default port in OPENAI_BASE_URL/ANTHROPIC_BASE_URL/GEMINI_API_BASE_URL is lost before it reaches AWF.

💡 Why this blocks the fix

extractAPITargetHost strips the path and normalizes the authority down to the bare host string. With an input like (localhost/redacted) this branch emits (localhost/redacted) instead of `(localhost/redacted) so the proxy silently reconnects to port 80 and breaks the exact local/internal gateway setups this PR is trying to restore.

Please parse the URL once and preserve `(host/redacted) for explicit HTTP targets, or return the original authority component instead of reconstructing it from the already-stripped host.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added regression coverage for http://openai-gateway.example.com:8080/v1, confirming the compiler preserves the explicit http:// scheme and :8080 authority in the emitted AWF target. AWF may still normalize that port at runtime, as documented on AWFAPITargetConfig.Host.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
pr-sous-chef
```...

Updated the exported AWFAPITargetConfig.Host documentation and added the patch changeset for explicit HTTP API target schemes. The changes are in commit $(git -C /home/runner/work/gh-aw/gh-aw rev-parse --short HEAD). The AWF v0.28.13 version gate remains covered by the existing tests.

@github-actions github-actions 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.

Backend-only change (AWF proxy target host/scheme handling in pkg/workflow and pkg/constants); no UI surface, so Impeccable audit/critique/harden modes do not apply here.

Reviewed the diff for correctness/security: extractAPIProxyTargetHost safely reuses the already-validated extractAPITargetHost output, only re-adds (redacted) when the original env var literally started with it, and is version-gated via the existing awfVersionAtLeasthelper consistent with other AWF feature flags. Test coverage inawf_config_test.goexercises all scheme/version combinations (http/https/bare x old/new AWF version) end-to-end throughBuildAWFConfigJSON`.

No new blocking issues found. Two pre-existing review comments already flag: (1) missing changeset entry for this user-visible bug fix, and (2) stale doc comment on AWFAPITargetConfig.Host that still claims hostname-only after this change now allows a scheme prefix. Both are valid and should be addressed before merge.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 19 AIC · ⌖ 13.3 AIC · ⊞ 8.3K

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Cannot push to pull request branch: bundle modifies files outside the allowed-files list (.changeset/patch-preserve-http-api-target-schemes.md, pkg/workflow/awf_config.go). Add the files to the allowed-files configuration field or remove them from the bundle.. The code changes were not applied.

🏗️ ADR Required - draft added for PR #58608

I enforced the design-decision gate for this PR because it adds more than 100 new lines in business-logic directories (pkg/: 123 additions).

Evidence reviewed

  • PR title: Preserve explicit HTTP schemes in AWF API proxy targets
  • PR body states the change preserves `(redacted) for OpenAI, Anthropic, and Gemini proxy targets and keeps older AWF versions compatible.
  • Diff updates AWF config generation, version-gated feature flags, and tests across:
    • pkg/workflow/awf_config_build.go
    • pkg/workflow/engine_api_targets.go
    • pkg/workflow/awf_feature_flags.go
    • pkg/constants/version_constants.go
    • pkg/workflow/awf_config_test.go

Gate result

No existing ADR was found in the PR body or on the branch for this decision, so I generated a draft ADR and committed it to:

  • docs/adr/58608-preserve-explicit-http-schemes-in-awf-api-proxy-targets.md

Next action

Please review and refine the draft ADR, then keep it with this PR as the architectural record for the version-gated decision to preserve explicit HTTP API proxy target schemes.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · gpt54 · 15.3 AIC · ⌖ 7.24 AIC · ⊞ 10.1K ·
Comment /review to run again

@github-actions github-actions 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.

Skills-Based Review 🧠

Applied /codebase-design — the core fix (preserving (redacted) for API proxy targets, gated behind AWFHTTPAPITargetMinVersion) is sound, well-tested across engines/version boundaries, and consistent with the existing feature-flag pattern (awfSupports*`).

📋 Key Themes & Highlights

Key Themes

  • Two existing bot comments on engine_api_targets.go (missing changeset, stale Host doc comment) remain valid and unaddressed — both are quick fixes, not blockers.
  • Gemini fallback ordering is correct: extractAPIProxyTargetHost is tried first, falling back to GetGeminiAPITarget's default host, preserving existing default-target behavior for the gemini engine.

Positive Highlights

  • ✅ New helper extractAPIProxyTargetHost cleanly layers scheme-preservation on top of extractAPITargetHost without duplicating hostname-extraction logic.
  • ✅ Version gating via awfSupportsHTTPAPITargets follows the established awfSupports* feature-flag convention exactly.
  • ✅ Table-driven test covers min-version boundary, newer version, older version (bare fallback), HTTPS (bare), and scheme-less inputs — good edge-case coverage per /tdd.

Approving since the logic and tests are solid; the two inline suggestions (changeset + doc comment) are worth a quick follow-up but don't block merge.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 48.5 AIC · ⌖ 16 AIC · ⊞ 10.3K
Comment /matt to run again


// extractAPIProxyTargetHost returns the target host format expected by the
// effective AWF version, preserving an explicit http:// scheme when supported.
func extractAPIProxyTargetHost(workflowData *WorkflowData, envVar string, firewallConfig *FirewallConfig) string {

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.

[/codebase-design] Missing changeset: this is a user-visible bug fix (HTTP scheme stripping caused wrong-port connections) but there's no .changeset/*.md entry, matching the existing bot review comment on this line.

💡 Suggested fix

Add .changeset/patch-preserve-http-api-proxy-target-scheme.md (or similar) with a patch bump describing the fix, following the pattern of other entries like patch-enforce-http-mcp-oidc-awf-version.md.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The patch changeset is present at .changeset/patch-preserve-http-api-target-schemes.md, documenting the user-visible HTTP target scheme fix.

}

if strings.HasPrefix(workflowData.EngineConfig.Env[envVar], "http://") {
return "http://" + host

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.

[/codebase-design] Doc/behavior mismatch: AWFAPITargetConfig.Host at pkg/workflow/awf_config.go:231 is documented as "the hostname (and optional port)", but this function can now return a value with an `(redacted) prefix, contradicting the field's stated contract.

💡 Suggested fix

Update the doc comment on Host to note it may include an explicit (redacted) scheme when the effective AWF version supports it (>= AWFHTTPAPITargetMinVersion`), so future readers of the struct aren't misled by the field name.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated AWFAPITargetConfig.Host documentation to cover explicit http:// targets when supported by the effective AWF version, including the current AWF custom-port normalization limitation.

@lpcox lpcox left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is compatible with AWF v0.28.13+: AWF preserves an explicit http:// target, routes it over cleartext HTTP, and derives the matching firewall allowlist entry. The version gate also preserves the prior representation for older AWF versions.

One non-blocking caveat: AWF currently discards explicit target ports during normalization and dials fixed port 80 for HTTP (or 443 for HTTPS). Consequently, http://gateway.example.com works as intended, but http://gateway.example.com:8080 is emitted here with the port and then normalized by AWF to gateway.example.com:80. It would be useful to document that limitation or add a follow-up issue so users do not assume custom-port targets are supported.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator
pr-sous-chef

@copilot Please take the next forward-progress pass on this PR.

  • Review the current branch state, address any unresolved reviewer feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.
  • Summarize the current maintainer-facing blocker clearly once you finish.

Generated by PR Sous Chef: https://github.com/github/gh-aw/actions/runs/33927496336

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 17 AIC · ⌖ 9.78 AIC · ⊞ 9.2K ·
Comment /souschef to run again

Copilot AI and others added 2 commits September 4, 2026 23:07
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author
pr-sous-chef
```...

Documented the AWF target-port limitation in pkg/workflow/awf_config.go: explicit target ports are currently normalized by AWF to the scheme default, so custom-port targets are not supported. The version-gated scheme behavior remains unchanged.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot PR sous-chef triage: please address the remaining review feedback (explicit-port handling plus the noted follow-up cleanup items), refresh the branch if needed, and run the pr-finisher skill after pushing updates. Reviews: #58608 (review) and #58608 (review)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 24.2 AIC · ⌖ 8.7 AIC · ⊞ 8.9K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot PR sous-chef triage: please address the remaining review feedback (explicit-port handling plus the noted follow-up cleanup items), refresh the branch if needed, and run the pr-finisher skil...

Addressed the explicit-port feedback with regression coverage confirming the compiled target preserves http://host:8080, and added the requested draft ADR at docs/adr/58608-preserve-explicit-http-schemes-in-awf-api-proxy-targets.md. Targeted tests and fast validation pass.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Score: 67 | Breakdown: impact 36/urgency 18/quality 13 | Action: batch_review | Batch: awf-runtime

Generated by 🔧 PR Triage Agent · copilot · mai10 · 24 AIC · ⌖ 2.63 AIC · ⊞ 15.1K ·

@pelikhan
pelikhan merged commit 233a703 into main Sep 5, 2026
2 checks passed
@pelikhan
pelikhan deleted the copilot/fix-api-target-scheme-stripping branch September 5, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http:// API targets: scheme stripped from apiProxy.targets.<provider>.host, defeating AWF v0.28.13 HTTP support

5 participants