Skip to content

test(command): cover Quote escape behavior - #1072

Open
devsy-app[bot] wants to merge 3 commits into
mainfrom
pkg-core-agent/quote-escape-tests
Open

test(command): cover Quote escape behavior#1072
devsy-app[bot] wants to merge 3 commits into
mainfrom
pkg-core-agent/quote-escape-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/command — the Quote helper in pkg/command/escape.go.

Issue found

Quote had no dedicated test coverage. Its behavior is non-obvious and easy to regress:

  • nil/empty input → returns ""
  • a single arg → returned unquoted (passthrough), e.g. ["agent internal ssh-git-clone"]agent internal ssh-git-clone
  • multiple args → shell-quoted and joined via shellescape.QuoteCommand (with embedded single-quote escaping)

This helper is security-adjacent: it is used in pkg/agent/workspace.go to build the GIT_SSH_COMMAND string passed to the shell, so a regression in its escaping could break quoting of paths/keys containing spaces or special characters.

Change

Add pkg/command/escape_test.go — a table-driven test (TestQuote) that locks in all three branches plus the tricky embedded-single-quote escaping case:

  • empty (nil and []string{})
  • single-arg passthrough (with and without spaces)
  • multi-arg shell-quoted join
  • arg containing a space (single-quoted)
  • arg containing an embedded single quote (''"'"')

No behavior change — pure test addition.

Verification performed

  • task cli:format — clean
  • task cli:lint:ci0 issues
  • task cli:testpkg/command passes; the only failure is the known pre-existing pkg/git TestRepoClone* stale-assertion failure (untouched by this change)
  • go test ./pkg/command/ -run TestQuote -v — all subtests PASS

Commit be4a99d is app-signed (verified=true).

This PR was created by an AI agent as part of an automated daily package review job.

Add table-driven test for pkg/command Quote covering empty, single-arg passthrough, multi-arg join, and special-char escaping.
@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 40c1058
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a829ea83b7d7e000875250b

@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 40c1058
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a829ea884aaf400082aaa67

@codacy-production

codacy-production Bot commented Aug 16, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@github-actions github-actions Bot added size/m and removed size/s labels Aug 17, 2026
@skevetter
skevetter marked this pull request as ready for review August 17, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant