Skip to content

Add safe URL construction rules to agent guides#1100

Merged
gearnode merged 1 commit intomainfrom
gearnode/safe-url-building-guide
Apr 24, 2026
Merged

Add safe URL construction rules to agent guides#1100
gearnode merged 1 commit intomainfrom
gearnode/safe-url-building-guide

Conversation

@gearnode
Copy link
Copy Markdown
Contributor

@gearnode gearnode commented Apr 24, 2026

Summary

  • Add a "URL and query parameter construction" section to contrib/claude/go-style.md requiring net/url (url.URL, url.Values) instead of fmt.Sprintf or string concatenation
  • Add a matching TypeScript section to contrib/claude/httpclient.md requiring URL and URLSearchParams instead of template literals or string concatenation
  • Update CLAUDE.md index descriptions to reference the new sections

Test plan

  • Verify the guide renders correctly on GitHub
  • Confirm cross-references between Go and TypeScript sections link properly

Summary by cubic

Add safe URL construction rules to the Go style guide and add a new TypeScript style guide. Uses structured URL APIs and fixes Go examples to avoid double-encoding and parse errors.

  • New Features

    • Go: Added “URL and query parameter construction” requiring net/url (url.URL, url.Values); prefer url.JoinPath; recommend pkg/baseurl.URLBuilder; forbid fmt.Sprintf/concat.
    • TypeScript: New contrib/claude/ts-style.md; require URL and URLSearchParams; escape path segments with encodeURIComponent.
    • Index: Updated AGENTS.md to note Go rules and link ts-style.md.
  • Bug Fixes

    • Go examples now use url.Values + RawQuery and url.JoinPath to avoid double-encoding and query concat errors.
    • Added error handling around url.Parse.

Written for commit f82d76b. Summary will update on new commits.

@gearnode gearnode requested a review from a team April 24, 2026 08:29
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="contrib/claude/httpclient.md">

<violation number="1" location="contrib/claude/httpclient.md:57">
P2: The “good” example should encode dynamic path segments; raw interpolation into `pathname` can break path structure when values contain reserved characters like `/`.</violation>
</file>

<file name="contrib/claude/go-style.md">

<violation number="1" location="contrib/claude/go-style.md:198">
P2: Escape dynamic path segments in the “Good” example; joining raw `userID` can change URL path semantics.</violation>

<violation number="2" location="contrib/claude/go-style.md:221">
P2: The “Good” example still constructs a URL by concatenating strings; parse the base URL and set `RawQuery` instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread contrib/claude/httpclient.md Outdated
Comment thread contrib/claude/go-style.md Outdated
Comment thread contrib/claude/go-style.md Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="contrib/claude/go-style.md">

<violation number="1" location="contrib/claude/go-style.md:198">
P2: This example double-encodes path segments by putting `url.PathEscape(...)` directly into `url.URL.Path`. Use `Path` with the unescaped value and `RawPath` with the escaped value.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread contrib/claude/go-style.md Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="contrib/claude/go-style.md">

<violation number="1" location="contrib/claude/go-style.md:200">
P2: Do not ignore `url.Parse` errors in the “Good” example; handle and wrap the error consistently.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread contrib/claude/go-style.md Outdated
Add a URL and query parameter construction section to
contrib/claude/go-style.md requiring net/url (url.JoinPath,
url.Values, url.Parse) instead of fmt.Sprintf or string
concatenation.

Create contrib/claude/ts-style.md with matching TypeScript
rules requiring URL and URLSearchParams instead of template
literals or string concatenation.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
@gearnode gearnode force-pushed the gearnode/safe-url-building-guide branch from cb86d75 to f82d76b Compare April 24, 2026 14:12
@gearnode gearnode merged commit f82d76b into main Apr 24, 2026
17 checks passed
@gearnode gearnode deleted the gearnode/safe-url-building-guide branch April 24, 2026 14:16
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.

2 participants