Skip to content

Commit a96e1ec

Browse files
authored
feat: Warn on usage with plugins with SDK < v0.13 (#2696)
#### Summary Example: ![image](https://user-images.githubusercontent.com/26760571/195351567-102990a6-1c07-4353-a135-37531c103444.png) <!--
1 parent 0e5d974 commit a96e1ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cli/cmd/sync.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cloudquery sync ./directory
2121
# Sync resources from directories and files
2222
cloudquery sync ./directory ./aws.yml ./pg.yml
2323
`
24+
unknownFieldErrorPrefix = "code = InvalidArgument desc = failed to decode spec: json: unknown field "
2425
)
2526

2627
func NewCmdSync() *cobra.Command {
@@ -129,6 +130,9 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
129130
g.Go(func() error {
130131
defer close(resources)
131132
if err := sourceClient.Sync(gctx, sourceSpec, resources); err != nil {
133+
if isUnknownConcurrencyFieldError(err) {
134+
return fmt.Errorf("unsupported version of source %s@%s. Please update to the latest version from https://cloudquery.io/docs/plugins/sources", sourceSpec.Name, sourceSpec.Version)
135+
}
132136
return fmt.Errorf("failed to sync source %s: %w", sourceSpec.Name, err)
133137
}
134138
return nil
@@ -196,3 +200,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
196200
Int("resources", totalResources).Uint64("errors", summary.Errors).Uint64("panic", summary.Panics).Uint64("failed_writes", failedWrites).Float64("time_took", tt.Seconds()).Msg("Sync completed successfully")
197201
return nil
198202
}
203+
204+
func isUnknownConcurrencyFieldError(err error) bool {
205+
return strings.Contains(err.Error(), unknownFieldErrorPrefix+`"table_concurrency"`) || strings.Contains(err.Error(), unknownFieldErrorPrefix+`"resource_concurrency"`)
206+
}

0 commit comments

Comments
 (0)