Skip to content
Draft
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
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ linters:
- noctx
- unconvert
settings:
errcheck:
check-blank: true
govet:
enable:
- unusedwrite
Expand All @@ -25,4 +27,4 @@ linters:
rules:
- linters:
- gosec
text: G115
text: G115
6 changes: 4 additions & 2 deletions cmd/airbyte-source/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ func CheckCommand(ch *Helper) *cobra.Command {
}
}()

cs, _ := checkConnectionStatus(ch.Database, psc)
cs, err := checkConnectionStatus(ch.Database, psc)
if err != nil {
Copy link

Copilot AI Apr 3, 2025

Choose a reason for hiding this comment

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

After logging the error in the 'if' block, consider altering the control flow to avoid using 'cs' when an error occurs. For example, returning from the function or using an alternative handling mechanism would prevent potential issues from processing an invalid connection status.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I tried doing that originally, but it broke tests. Let's add a // TODO here to fix that.

fmt.Fprintf(cmd.ErrOrStderr(), "Unable to check connection status for PlanetScale Database, failed with %v", err)
}
ch.Logger.ConnectionStatus(cs)
},
}
Expand All @@ -71,7 +74,6 @@ func parseSource(reader FileReader, configFilePath string) (internal.PlanetScale
}

func checkConnectionStatus(database internal.PlanetScaleDatabase, psc internal.PlanetScaleSource) (internal.ConnectionStatus, error) {

if err := database.CanConnect(context.Background(), psc); err != nil {
return internal.ConnectionStatus{
Status: "FAILED",
Expand Down
5 changes: 4 additions & 1 deletion cmd/internal/planetscale_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ func (psc PlanetScaleSource) GetInitialState(keyspaceOrDatabase string, shards [
}
}

cursor, _ := TableCursorToSerializedCursor(&psdbconnect.TableCursor{
cursor, err := TableCursorToSerializedCursor(&psdbconnect.TableCursor{
Shard: shard,
Keyspace: keyspaceOrDatabase,
Position: position,
})
if err != nil {
return shardCursors, fmt.Errorf("table cursor to serialized cursor: %w", err)
}
shardCursors.Shards[shard] = cursor
}

Expand Down