Skip to content

[Repo Assist] refactor(proxy): replace private truncateForLog with strutil.Truncate#2322

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/refactor-truncate-use-strutil-2026-03-22-c14d7b8abbd7fd70
Draft

[Repo Assist] refactor(proxy): replace private truncateForLog with strutil.Truncate#2322
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/refactor-truncate-use-strutil-2026-03-22-c14d7b8abbd7fd70

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

internal/proxy/handler.go contained a private truncateForLog helper that duplicates the behaviour of strutil.Truncate, which already exists as a shared utility used by internal/logger/rpc_helpers.go and internal/auth/header.go.

Changes

  • internal/proxy/handler.go:
    • Add import for github.com/github/gh-aw-mcpg/internal/strutil
    • Replace the single call to truncateForLog(string(graphQLBody), 500) with strutil.Truncate(string(graphQLBody), 500)
    • Remove the now-unused truncateForLog function (6 lines)

Rationale

The removed function was semantically identical to strutil.Truncate:

// Before (private copy in handler.go)
func truncateForLog(s string, maxLen int) string {
    if len(s) <= maxLen { return s }
    return s[:maxLen] + "..."
}

// After (shared utility — same behaviour)
strutil.Truncate(s, maxLen)  // returns s[:maxLen]+"..." if len(s) > maxLen

Using the shared utility:

  • Eliminates a redundant private implementation
  • Is consistent with the rest of the codebase (logger/rpc_helpers.go, auth/header.go both use strutil.Truncate)
  • Has no behaviour change — the semantics are identical

Test Status

  • gofmt -l internal/proxy/handler.go reports no formatting issues (file is clean)
  • Build requires Go 1.25 which cannot be downloaded in this sandboxed environment (firewall blocks proxy.golang.org). Code was verified syntactically via gofmt -e and logic-reviewed manually.
  • No test changes required — truncateForLog had no direct unit test, and the call site behaviour is unchanged.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

Warning

⚠️ Firewall blocked 1 domain

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

  • proxy.golang.org

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

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

truncateForLog in handler.go is a private helper that duplicates the
behaviour of strutil.Truncate, which already exists as a shared utility
and is used by logger/rpc_helpers.go and auth/header.go.

Remove the private copy and use strutil.Truncate directly. The semantics
are identical: both truncate to maxLen characters and append '...' if the
string was longer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants