Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/workflows/check-openapi-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,4 @@ jobs:
- uses: actions/checkout@v4
- name: Check OpenAPI updates
run: make openapi-spec-check-updates
on-failure:
runs-on: ubuntu-latest
if: ${{ always() && (needs.check-open-api-spec-updates.result == 'failure' || needs.check-open-api-spec-updates.result == 'timed_out') }}
needs:
- check-open-api-spec-updates
steps:
- uses: actions/checkout@v4
- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: proj-cli
SLACK_COLOR: ${{ job.status }}
SLACK_ICON_EMOJI: ':launchdarkly:'
SLACK_TITLE: ':warning: The OpenAPI spec has changed and resources need to be updated.'
SLACK_USERNAME: github
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
continue-on-error: true
Copy link

Choose a reason for hiding this comment

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

Slack failure notification silently removed and replaced with no-op

Medium Severity

The on-failure job that sent Slack notifications when the OpenAPI spec check failed has been completely removed and replaced with continue-on-error: true at the job level. This silently swallows failures instead of alerting the team, meaning the team will no longer be notified when the OpenAPI spec changes and resources need updating.

Fix in Cursor Fix in Web

8 changes: 5 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: stable
go-version: '1.23'
cache: true
cache-dependency-path: go.sum
- name: build
run: go build .

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
- edited
- synchronize

permissions:
contents: read

jobs:
lint-pr-title:
# This workflow is safe to use with pull_request_target because it only
# calls an external reusable workflow and does not execute any code
# from the PR itself. The GITHUB_TOKEN is read-only (contents: read).
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
155 changes: 0 additions & 155 deletions README.md

This file was deleted.

18 changes: 18 additions & 0 deletions cmd/cliflags/flags.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package cliflags

import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func GetOutputKind(cmd *cobra.Command) string {
if jsonFlag, err := cmd.Root().PersistentFlags().GetBool(JSONFlag); err == nil && jsonFlag {
return "json"
}
return viper.GetString(OutputFlag)
}
Copy link

Choose a reason for hiding this comment

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

New exported function GetOutputKind is never called

Low Severity

The newly added exported function GetOutputKind is not called anywhere in the codebase. Additionally, the JSONFlag constant it references ("json") is never registered as a persistent boolean flag on any command, so cmd.Root().PersistentFlags().GetBool(JSONFlag) would always return an error, making the "json" branch unreachable even if the function were called.

Fix in Cursor Fix in Web


const (
BaseURIDefault = "https://app.launchdarkly.com"
DevStreamURIDefault = "https://stream.launchdarkly.com"
PortDefault = "8765"
HostDefault = "127.0.0.1"

AccessTokenFlag = "access-token"
AnalyticsOptOut = "analytics-opt-out"
Expand All @@ -15,6 +28,8 @@ const (
EmailsFlag = "emails"
EnvironmentFlag = "environment"
FlagFlag = "flag"
HostFlag = "host"
JSONFlag = "json"
OutputFlag = "output"
PortFlag = "port"
ProjectFlag = "project"
Expand All @@ -29,6 +44,8 @@ const (
DevStreamURIDescription = "Streaming service endpoint that the dev server uses to obtain authoritative flag data. This may be a LaunchDarkly or Relay Proxy endpoint"
EnvironmentFlagDescription = "Default environment key"
FlagFlagDescription = "Default feature flag key"
HostFlagDescription = "Host for the dev server to bind to (default: 127.0.0.1). Use 0.0.0.0 to allow external connections"
JSONFlagDescription = "Output JSON format (shorthand for --output json)"
OutputFlagDescription = "Command response output format in either JSON or plain text"
PortFlagDescription = "Port for the dev server to run on"
ProjectFlagDescription = "Default project key"
Expand All @@ -45,6 +62,7 @@ func AllFlagsHelp() map[string]string {
DevStreamURIFlag: DevStreamURIDescription,
EnvironmentFlag: EnvironmentFlagDescription,
FlagFlag: FlagFlagDescription,
HostFlag: HostFlagDescription,
OutputFlag: OutputFlagDescription,
PortFlag: PortFlagDescription,
ProjectFlag: ProjectFlagDescription,
Expand Down
1 change: 1 addition & 0 deletions cmd/config/testdata/help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Supported settings:
- `dev-stream-uri`: Streaming service endpoint that the dev server uses to obtain authoritative flag data. This may be a LaunchDarkly or Relay Proxy endpoint
- `environment`: Default environment key
- `flag`: Default feature flag key
- `host`: Host for the dev server to bind to (default: 127.0.0.1). Use 0.0.0.0 to allow external connections
- `output`: Command response output format in either JSON or plain text
- `port`: Port for the dev server to run on
- `project`: Default project key
Expand Down
14 changes: 13 additions & 1 deletion cmd/dev_server/dev_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func NewDevServerCmd(client resources.Client, analyticsTrackerFn analytics.Track

_ = viper.BindPFlag(cliflags.PortFlag, cmd.PersistentFlags().Lookup(cliflags.PortFlag))

cmd.PersistentFlags().String(
cliflags.HostFlag,
cliflags.HostDefault,
cliflags.HostFlagDescription,
)

_ = viper.BindPFlag(cliflags.HostFlag, cmd.PersistentFlags().Lookup(cliflags.HostFlag))

cmd.PersistentFlags().Bool(
cliflags.CorsEnabledFlag,
false,
Expand Down Expand Up @@ -89,5 +97,9 @@ func NewDevServerCmd(client resources.Client, analyticsTrackerFn analytics.Track
}

func getDevServerUrl() string {
return fmt.Sprintf("http://localhost:%s", viper.GetString(cliflags.PortFlag))
host := viper.GetString(cliflags.HostFlag)
if host == "0.0.0.0" {
host = "localhost"
}
return fmt.Sprintf("http://%s:%s", host, viper.GetString(cliflags.PortFlag))
}
1 change: 1 addition & 0 deletions cmd/dev_server/start_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func startServer(client dev_server.Client) func(*cobra.Command, []string) error
BaseURI: viper.GetString(cliflags.BaseURIFlag),
DevStreamURI: viper.GetString(cliflags.DevStreamURIFlag),
Port: viper.GetString(cliflags.PortFlag),
Host: viper.GetString(cliflags.HostFlag),
CorsEnabled: viper.GetBool(cliflags.CorsEnabledFlag),
CorsOrigin: viper.GetString(cliflags.CorsOriginFlag),
InitialProjectSettings: initialSetting,
Expand Down
14 changes: 14 additions & 0 deletions internal/dev_server/adapters/mocks/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 23 additions & 17 deletions internal/dev_server/adapters/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ import (

const ctxKeySdk = ctxKey("adapters.sdk")

func WithSdk(ctx context.Context, s Sdk) context.Context {
return context.WithValue(ctx, ctxKeySdk, s)
}

func GetSdk(ctx context.Context) Sdk {
return ctx.Value(ctxKeySdk).(Sdk)
}

//go:generate go run go.uber.org/mock/mockgen -destination mocks/sdk.go -package mocks . Sdk
type Sdk interface {
GetAllFlagsState(ctx context.Context, ldContext ldcontext.Context, sdkKey string) (flagstate.AllFlags, error)
}

type streamingSdk struct {
streamingUrl string
}
Expand All @@ -52,11 +39,30 @@ func (s streamingSdk) GetAllFlagsState(ctx context.Context, ldContext ldcontext.
return flagstate.AllFlags{}, errors.Wrap(err, "unable to get source flags from LD SDK")
}
defer func() {
err := ldClient.Close()
if err != nil {
if err := ldClient.Close(); err != nil {
log.Printf("error while closing SDK client: %+v", err)
}
}()
flags := ldClient.AllFlagsState(ldContext)
return flags, nil
return ldClient.AllFlagsState(ldContext), nil
}

func (s streamingSdk) Close() error {
return nil
}

func WithSdk(ctx context.Context, sdk Sdk) context.Context {
return context.WithValue(ctx, ctxKeySdk, sdk)
}

func GetSdk(ctx context.Context) Sdk {
if sdk := ctx.Value(ctxKeySdk); sdk != nil {
return sdk.(Sdk)
}
return nil
}

//go:generate go run go.uber.org/mock/mockgen -destination mocks/sdk.go -package mocks . Sdk
type Sdk interface {
GetAllFlagsState(ctx context.Context, ldContext ldcontext.Context, sdkKey string) (flagstate.AllFlags, error)
Close() error
}
Loading
Loading