Skip to content

Remove custom string matching helpers in favor of strings.Contains - #6829

Merged
trangevi merged 3 commits into
trangevi/init-from-codefrom
copilot/sub-pr-6828
Feb 20, 2026
Merged

Remove custom string matching helpers in favor of strings.Contains#6829
trangevi merged 3 commits into
trangevi/init-from-codefrom
copilot/sub-pr-6828

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

The test file contained hand-rolled containsString and searchString functions that duplicated strings.Contains from the standard library.

Changes

  • init_from_code_test.go: Removed containsString and searchString; updated containsAll to call strings.Contains directly; added "strings" import.
// Before
func containsAll(s string, substrings ...string) bool {
    for _, sub := range substrings {
        if !containsString(s, sub) { ... }
    }
}
func containsString(s, substr string) bool { return len(s) >= len(substr) && searchString(s, substr) }
func searchString(s, substr string) bool   { /* manual byte-by-byte scan */ }

// After
func containsAll(s string, substrings ...string) bool {
    for _, sub := range substrings {
        if !strings.Contains(s, sub) { ... }
    }
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 20, 2026 22:10
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on init from code flow Remove custom string matching helpers in favor of strings.Contains Feb 20, 2026
Copilot AI requested a review from trangevi February 20, 2026 22:11
@trangevi
trangevi marked this pull request as ready for review February 20, 2026 22:35
@trangevi
trangevi merged commit 8d78814 into trangevi/init-from-code Feb 20, 2026
13 checks passed
@trangevi
trangevi deleted the copilot/sub-pr-6828 branch February 20, 2026 22:35
trangevi added a commit that referenced this pull request Feb 24, 2026
* Add support for init from code

Signed-off-by: trangevi <trangevi@microsoft.com>

* Code comment

Signed-off-by: trangevi <trangevi@microsoft.com>

* Addressing some comments

Signed-off-by: trangevi <trangevi@microsoft.com>

* make sure src is provided for local code story for now

Signed-off-by: trangevi <trangevi@microsoft.com>

* some fixes

Signed-off-by: trangevi <trangevi@microsoft.com>

* Add manual defaulting

Signed-off-by: trangevi <trangevi@microsoft.com>

* Refactoring a bunch based on expected experience

Signed-off-by: trangevi <trangevi@microsoft.com>

* broken spinner

Signed-off-by: trangevi <trangevi@microsoft.com>

* Remove env var print

* Add support for --project-id

Signed-off-by: trangevi <trangevi@microsoft.com>

* Missing env var

Signed-off-by: trangevi <trangevi@microsoft.com>

* Address feedback

Signed-off-by: trangevi <trangevi@microsoft.com>

* Switch to public repo

Signed-off-by: trangevi <trangevi@microsoft.com>

* Changes for existing ACR

Signed-off-by: trangevi <trangevi@microsoft.com>

* More for existing ACR support

Signed-off-by: trangevi <trangevi@microsoft.com>

* app insights changes

Signed-off-by: trangevi <trangevi@microsoft.com>

* Point to branch for now

Signed-off-by: trangevi <trangevi@microsoft.com>

* tests

Signed-off-by: trangevi <trangevi@microsoft.com>

* Integrate with azd extension model handling

Signed-off-by: trangevi <trangevi@microsoft.com>

* Move model handling

Signed-off-by: trangevi <trangevi@microsoft.com>

* Update cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Proper http client handling

Signed-off-by: trangevi <trangevi@microsoft.com>

* Remove custom string matching helpers in favor of strings.Contains (#6829)

* Initial plan

* Replace containsString/searchString with strings.Contains in test file

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* Revert unrelated go.mod/go.sum changes

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* cspell

Signed-off-by: trangevi <trangevi@microsoft.com>

* Fix path traversal vulnerability in init_from_code template file download (#6830)

* Initial plan

* Use filepath.Clean() for path validation to prevent path traversal attacks

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* Revert unrelated go.mod/go.sum changes

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* fix: capture error from loadAiCatalog in selectNewModel (#6831)

* Initial plan

* fix: capture error from loadAiCatalog in selectNewModel

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* fix: revert go.mod/go.sum changes and add user-facing error message for loadAiCatalog failure

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* fix: remove fmt.Printf from loadAiCatalog error path

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>

* Code review

Signed-off-by: trangevi <trangevi@microsoft.com>

* Put the status check before attempting to use the response

Signed-off-by: trangevi <trangevi@microsoft.com>

* Fix path handling

Signed-off-by: trangevi <trangevi@microsoft.com>

* Remove unused code

Signed-off-by: trangevi <trangevi@microsoft.com>

* cspell

Signed-off-by: trangevi <trangevi@microsoft.com>

* Address PR comment

Signed-off-by: trangevi <trangevi@microsoft.com>

---------

Signed-off-by: trangevi <trangevi@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
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