Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Addresses missing null and empty checks when accessing Application Insights connection credentials. The Key field is marked omitempty in the JSON struct, making it potentially absent from API responses.

Changes

  • Validate credentials before use: Check Credentials.Key is non-empty before setting APPLICATIONINSIGHTS_CONNECTION_STRING environment variable
  • Fail fast on prompt errors: Return error immediately when connection selection prompt fails, rather than continuing with nil connection

Example

// Before: Could panic or set empty connection string
if err := a.setEnvVar(ctx, "APPLICATIONINSIGHTS_CONNECTION_STRING", selectedConnection.Credentials.Key); err != nil {
    return err
}

// After: Validate before use
if selectedConnection.Credentials.Key == "" {
    return fmt.Errorf("Application Insights connection '%s' has no credentials key", selectedConnection.Name)
}
if err := a.setEnvVar(ctx, "APPLICATIONINSIGHTS_CONNECTION_STRING", selectedConnection.Credentials.Key); err != nil {
    return err
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 7, 2026 22:20
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
… nil connection

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on AppInsights connection retrieval Add credential validation for App Insights connection retrieval Jan 7, 2026
Copilot AI requested a review from trangevi January 7, 2026 22:25
@trangevi trangevi closed this Jan 7, 2026
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