-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for custom actions. #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds configurable, query-driven actions with runtime registration and execution; extends config with Action and Argument types and validation; exposes RunProvisioningQueries and NewActionSyncer for action execution; updates callers and dependency versions; adds a TODO for SQL connection validation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Connector
participant Config as "Config (Actions)"
participant SDK as "CustomActionManager"
User->>Connector: Initialize connector
Connector->>Config: Load Actions
Connector->>Connector: Validate ActionConfig(s)
alt validation error
Connector-->>User: Return error
else
Connector->>SDK: Register action schemas & handlers
SDK-->>Connector: Manager ready
Connector-->>User: Initialization complete
end
sequenceDiagram
autonumber
actor Caller
participant SDK as "CustomActionManager"
participant Connector
participant Syncer as "SQLSyncer / ActionSyncer"
participant DB as "SQL Backend"
Caller->>SDK: Invoke Action(name, args)
SDK->>Connector: handleQueryAction(name, args)
Connector->>Syncer: NewActionSyncer(...) / prepare vars
Connector->>Syncer: RunProvisioningQueries(ctx, queries, vars, useTx)
Syncer->>DB: Execute queries
alt success
DB-->>Syncer: Result(s)
Syncer-->>Connector: Success
Connector-->>SDK: Struct payload + annotations
SDK-->>Caller: Success
else error
DB-->>Syncer: Error
Syncer-->>Connector: Wrapped error
Connector-->>SDK: Error response
SDK-->>Caller: Error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (296)
examples/postgres-test.ymlis excluded by none and included by nonego.sumis excluded by!**/*.sumand included by nonevendor/github.com/conductorone/baton-sdk/pkg/actions/actions.gois excluded by!vendor/**and included by nonevendor/github.com/conductorone/baton-sdk/pkg/sdk/version.gois excluded by!vendor/**and included by nonevendor/github.com/conductorone/baton-sdk/pkg/tasks/c1api/hello.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/.gitignoreis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/LICENSEis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/README.mdis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/abi_amd64.his excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/abi_arm64.his excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/cgo.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlerror.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_android.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_linux.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_playground.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/dlfcn_stubs.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/func.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/go_runtime.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/cgo/empty.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.his excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.his excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/doc.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_linux_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/go_util.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/setenv.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/symbols.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/symbols_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/symbols_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/symbols_linux.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_stubs.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/internal/strings/strings.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/is_ios.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/struct_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/struct_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/struct_other.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/sys_amd64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/sys_arm64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/sys_unix_arm64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/syscall.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/syscall_cgo_linux.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/syscall_sysv.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/syscall_windows.gois excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/zcallback_amd64.sis excluded by!vendor/**and included by nonevendor/github.com/ebitengine/purego/zcallback_arm64.sis excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/cpu/cpu_darwin_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/host/host_darwin_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/host/host_darwin_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/host/host_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/host/smc_darwin.cis excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/host/smc_darwin.his excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/internal/common/binary.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/internal/common/common_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/mem/mem_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/mem/mem_darwin_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/mem/mem_darwin_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/net/net_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/net/net_linux_111.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/net/net_linux_116.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_bsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_darwin_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_darwin_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_freebsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v3/process/process_plan9.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/LICENSEis excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/common/env.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd_riscv64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_aix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_aix_ppc64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_bsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_darwin_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_darwin_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_freebsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_freebsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_freebsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_freebsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_loong64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_mips.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_mips64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_mips64le.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_mipsle.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_ppc64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_ppc64le.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_riscv64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_linux_s390x.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_netbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_openbsd_riscv64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_posix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_solaris.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/host/host_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_netbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_unix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/endian.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/readlink_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/sleep.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/internal/common/warnings.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/ex_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/ex_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_aix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_aix_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_aix_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_bsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd_riscv64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/mem/mem_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_aix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_solaris.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_unix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/net/net_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_bsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_darwin.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_darwin_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_darwin_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_fallback.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_freebsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_freebsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_freebsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_freebsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_linux.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd_386.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd_amd64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd_arm64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_openbsd_riscv64.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_plan9.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_posix.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_solaris.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_windows.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.gois excluded by!vendor/**and included by nonevendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.gois excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/.golangci.yamlis excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/LICENSEis excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/Makefileis excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/README.mdis excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/cpu.gois excluded by!vendor/**and included by nonevendor/github.com/shoenig/go-m1cpu/incompatible.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/assertion_compare.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/assertion_format.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/assertion_forward.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/assertion_order.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/assertions.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/doc.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/http_assertions.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/yaml/yaml_custom.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/yaml/yaml_default.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/assert/yaml/yaml_fail.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/require/doc.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/require/require.gois excluded by!vendor/**and included by nonevendor/github.com/stretchr/testify/require/require_forward.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/cpu/cpu.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/cpu/cpu_linux_riscv64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/cpu/cpu_riscv64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/mkerrors.shis excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/syscall_darwin.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_386.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_amd64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_arm.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_arm64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_loong64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_mips.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_mips64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_mips64le.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_mipsle.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_ppc.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_ppc64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_riscv64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_s390x.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zerrors_linux_sparc64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_386.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_amd64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_arm.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_arm64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_loong64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_mips.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_mips64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_ppc.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_s390x.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_386.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_amd64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_arm.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_arm64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_loong64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_mips.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_mips64.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_mips64le.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_mipsle.gois excluded by!vendor/**and included by nonevendor/golang.org/x/sys/unix/ztypes_linux_ppc.gois excluded by!vendor/**and included by none
📒 Files selected for processing (4)
go.mod(5 hunks)pkg/bsql/config.go(3 hunks)pkg/connector/action.go(1 hunks)pkg/connector/connector.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Error handling: usefmt.Errorfwith contextual messages; check specific errors witherrors.Is
Organize imports: standard library first, then third-party, then project imports; alphabetize within each group
Naming: CamelCase for exported identifiers; camelCase for unexported; preserve acronyms like ID, URL, HTTP, API
Limit line length to a maximum of 200 characters
Comments for exported items must be complete sentences ending with periods
Do not uselog.Fatalorlog.Panic(ruleguard-enforced)
Files:
pkg/connector/connector.gopkg/connector/action.gopkg/bsql/config.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Cursor Bugbot
- GitHub Check: go-lint
- GitHub Check: test
- GitHub Check: go-test (ubuntu-latest)
🔇 Additional comments (1)
go.mod (1)
98-98: Remove gopsutil import path update check
Search shows nogithub.com/shirou/gopsutilimports in the codebase (it’s marked indirect in go.mod), so no import path updates are needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
examples/postgres-test.ymlis excluded by none and included by none
📒 Files selected for processing (5)
pkg/bsql/provisioning.go(2 hunks)pkg/bsql/query.go(2 hunks)pkg/bsql/sql_syncer.go(1 hunks)pkg/bsql/user_syncer.go(2 hunks)pkg/connector/action.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Error handling: usefmt.Errorfwith contextual messages; check specific errors witherrors.Is
Organize imports: standard library first, then third-party, then project imports; alphabetize within each group
Naming: CamelCase for exported identifiers; camelCase for unexported; preserve acronyms like ID, URL, HTTP, API
Limit line length to a maximum of 200 characters
Comments for exported items must be complete sentences ending with periods
Do not uselog.Fatalorlog.Panic(ruleguard-enforced)
Files:
pkg/bsql/sql_syncer.gopkg/bsql/user_syncer.gopkg/bsql/query.gopkg/connector/action.gopkg/bsql/provisioning.go
🧬 Code graph analysis (3)
pkg/bsql/sql_syncer.go (3)
pkg/database/database.go (1)
DbEngine(20-20)pkg/bcel/bcel.go (1)
Env(17-19)pkg/bsql/config.go (1)
Config(17-32)
pkg/bsql/query.go (1)
pkg/bsql/sql_syncer.go (1)
SQLSyncer(20-27)
pkg/connector/action.go (3)
pkg/connector/connector.go (1)
Connector(18-23)pkg/bsql/config.go (1)
ActionConfig(412-422)pkg/bsql/sql_syncer.go (1)
NewActionSyncer(62-70)
🔇 Additional comments (1)
pkg/connector/action.go (1)
108-115: Fix closure capture before registering actions.
actionCfgandactionSchemaare reused loop variables. Every handler will close over the final iteration’s values, so every registered action ends up executing with the last config/schema. Copy them to per-iteration locals before registering the closure.Apply this diff:
- err := actionManager.RegisterAction(ctx, actionKey, actionSchema, func(ctx context.Context, args *structpb.Struct) (*structpb.Struct, annotations.Annotations, error) { - return c.handleQueryAction(ctx, actionCfg, actionSchema, args) + cfg := actionCfg + schema := actionSchema + + err := actionManager.RegisterAction(ctx, actionKey, schema, func(ctx context.Context, args *structpb.Struct) (*structpb.Struct, annotations.Annotations, error) { + return c.handleQueryAction(ctx, cfg, schema, args) })
| switch argCfg.Type { | ||
| case "string": | ||
| stringField := &config_sdk.StringField{} | ||
| if defaultValue != nil { | ||
| stringField.DefaultValue = defaultValue.(string) | ||
| } | ||
| arg.Field = &config_sdk.Field_StringField{StringField: stringField} | ||
| case "boolean": | ||
| boolField := &config_sdk.BoolField{} | ||
| if defaultValue != nil { | ||
| boolField.DefaultValue = defaultValue.(bool) | ||
| } | ||
| arg.Field = &config_sdk.Field_BoolField{BoolField: boolField} | ||
| case "number": | ||
| intField := &config_sdk.IntField{} | ||
| if defaultValue != nil { | ||
| intField.DefaultValue = defaultValue.(int64) | ||
| } | ||
| arg.Field = &config_sdk.Field_IntField{IntField: intField} | ||
| case "string_list": | ||
| stringSliceField := &config_sdk.StringSliceField{} | ||
| if defaultValue != nil { | ||
| stringSliceField.DefaultValue = defaultValue.([]string) | ||
| } | ||
| arg.Field = &config_sdk.Field_StringSliceField{StringSliceField: stringSliceField} | ||
| case "string_map": | ||
| stringMapField := &config_sdk.StringMapField{} | ||
| if defaultValue != nil { | ||
| stringMapField.DefaultValue = defaultValue.(map[string]*anypb.Any) | ||
| } | ||
| arg.Field = &config_sdk.Field_StringMapField{StringMapField: stringMapField} | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard default-value conversions to avoid panics.
Each defaultValue.(…) assertion will panic whenever the config supplies a valid default that doesn’t already have the exact target type (e.g., YAML/JSON numbers decode as int/float64, not int64). Convert via a type switch (and return a validation error on mismatch) before populating the proto fields.
Example fix:
- case "number":
- intField := &config_sdk.IntField{}
- if defaultValue != nil {
- intField.DefaultValue = defaultValue.(int64)
- }
- arg.Field = &config_sdk.Field_IntField{IntField: intField}
+ case "number":
+ intField := &config_sdk.IntField{}
+ switch v := defaultValue.(type) {
+ case nil:
+ case int, int32, int64:
+ intField.DefaultValue = int64(reflect.ValueOf(v).Int())
+ case float32, float64:
+ intField.DefaultValue = int64(reflect.ValueOf(v).Float())
+ default:
+ return nil, fmt.Errorf("invalid numeric default for %s: %T", actionKey, defaultValue)
+ }
+ arg.Field = &config_sdk.Field_IntField{IntField: intField}Apply the same pattern for the other branches (string, boolean, string_list, string_map) so config-supplied defaults cannot crash the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
pkg/connector/action.go (3)
3-18: Organize imports per project standards.Group as: standard library, third‑party, then project imports; alphabetize within each group. Move
github.com/conductorone/baton-sql/pkg/bsqlto the project group (last). Run goimports to enforce. As per coding guidelines.
20-27: Document exported symbol or make it unexported.Add a doc comment for
ActionTypeMap(exported), or unexport it if not required outside this package. As per coding guidelines.+// ActionTypeMap maps action_type strings from config to v2.ActionType enums. var ActionTypeMap = map[string]v2.ActionType{
59-69: Ensure argument Name is set (fallback to config key) and cascade DisplayName.If
argCfg.Nameis empty, schema and request parsing will use an empty field name. Fall back to the map key for stability.- for _, argCfg := range actionCfg.Arguments { + for k, argCfg := range actionCfg.Arguments { arg := &config_sdk.Field{ Name: argCfg.Name, DisplayName: argCfg.DisplayName, Description: argCfg.Description, IsRequired: argCfg.Required, } - if arg.DisplayName == "" { - arg.DisplayName = argCfg.Name - } + if arg.Name == "" { + arg.Name = k + } + if arg.DisplayName == "" { + arg.DisplayName = arg.Name + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/connector/action.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Error handling: usefmt.Errorfwith contextual messages; check specific errors witherrors.Is
Organize imports: standard library first, then third-party, then project imports; alphabetize within each group
Naming: CamelCase for exported identifiers; camelCase for unexported; preserve acronyms like ID, URL, HTTP, API
Limit line length to a maximum of 200 characters
Comments for exported items must be complete sentences ending with periods
Do not uselog.Fatalorlog.Panic(ruleguard-enforced)
Files:
pkg/connector/action.go
🧬 Code graph analysis (1)
pkg/connector/action.go (3)
pkg/connector/connector.go (1)
Connector(18-23)pkg/bsql/config.go (1)
ActionConfig(412-422)pkg/bsql/sql_syncer.go (1)
NewActionSyncer(62-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cursor Bugbot
🔇 Additional comments (4)
pkg/connector/action.go (4)
118-120: Closure capture fix looks good.Using per‑iteration locals (
cfg,schema) avoids capturing range variables.
111-113: Good validation for required query.Early return on missing
Queryis correct.
69-107: Fix unsafe default-value assertions (panic risk) and coerce types.Type assertions on
defaultValuefor string/bool/list/map will panic for valid YAML/JSON values (e.g.,[]any,map[string]any). Guard with type switches and convert.switch argCfg.Type { case "string": stringField := &config_sdk.StringField{} - if defaultValue != nil { - stringField.DefaultValue = defaultValue.(string) - } + switch v := defaultValue.(type) { + case nil: + case string: + stringField.DefaultValue = v + default: + return nil, fmt.Errorf("invalid string default for %s.%s: %T", actionKey, argCfg.Name, defaultValue) + } arg.Field = &config_sdk.Field_StringField{StringField: stringField} case "boolean": boolField := &config_sdk.BoolField{} - if defaultValue != nil { - boolField.DefaultValue = defaultValue.(bool) - } + switch v := defaultValue.(type) { + case nil: + case bool: + boolField.DefaultValue = v + default: + return nil, fmt.Errorf("invalid boolean default for %s.%s: %T", actionKey, argCfg.Name, defaultValue) + } arg.Field = &config_sdk.Field_BoolField{BoolField: boolField} case "number": intField := &config_sdk.IntField{} switch v := defaultValue.(type) { case nil: case int, int32, int64: intField.DefaultValue = reflect.ValueOf(v).Int() case float32, float64: intField.DefaultValue = int64(reflect.ValueOf(v).Float()) default: return nil, fmt.Errorf("invalid numeric default for %s: %T", actionKey, defaultValue) } arg.Field = &config_sdk.Field_IntField{IntField: intField} case "string_list": stringSliceField := &config_sdk.StringSliceField{} - if defaultValue != nil { - stringSliceField.DefaultValue = defaultValue.([]string) - } + switch v := defaultValue.(type) { + case nil: + case []string: + stringSliceField.DefaultValue = v + case []interface{}: + strs := make([]string, 0, len(v)) + for _, it := range v { + strs = append(strs, fmt.Sprint(it)) + } + stringSliceField.DefaultValue = strs + default: + return nil, fmt.Errorf("invalid string_list default for %s.%s: %T", actionKey, argCfg.Name, defaultValue) + } arg.Field = &config_sdk.Field_StringSliceField{StringSliceField: stringSliceField} case "string_map": stringMapField := &config_sdk.StringMapField{} - if defaultValue != nil { - stringMapField.DefaultValue = defaultValue.(map[string]*anypb.Any) - } + switch m := defaultValue.(type) { + case nil: + case map[string]string: + out := make(map[string]*anypb.Any, len(m)) + for k, v := range m { + av, _ := anypb.New(structpb.NewStringValue(v)) + out[k] = av + } + stringMapField.DefaultValue = out + case map[string]interface{}: + out := make(map[string]*anypb.Any, len(m)) + for k, v := range m { + sv, ok := v.(string) + if !ok { + return nil, fmt.Errorf("invalid string_map default for %s.%s: value for key %q is %T (want string)", actionKey, argCfg.Name, k, v) + } + av, _ := anypb.New(structpb.NewStringValue(sv)) + out[k] = av + } + stringMapField.DefaultValue = out + default: + return nil, fmt.Errorf("invalid string_map default for %s.%s: %T", actionKey, argCfg.Name, defaultValue) + } arg.Field = &config_sdk.Field_StringMapField{StringMapField: stringMapField} }Based on learnings.
140-165: Validate incoming args, guard nils, and normalize types (prevent panics).Current code can deref nil (e.g.,
GetListValue().Values) and passes[]*structpb.Valueinstead of[]string. Also unify numbers toint64.- var argMap = make(map[string]any) - for k, v := range actionCfg.Arguments { - if _, ok := args.Fields[v.Name]; !ok { + argMap := make(map[string]any) + fields := map[string]*structpb.Value{} + if args != nil && args.GetFields() != nil { + fields = args.GetFields() + } + for k, v := range actionCfg.Arguments { + name := v.Name + if name == "" { + name = k + } + pbArg, ok := fields[name] + if !ok || pbArg == nil { if v.Required { - return nil, nil, fmt.Errorf("argument %s is required", v.Name) + return nil, nil, fmt.Errorf("missing required argument %q", name) } if v.Default != nil { argMap[k] = v.Default } continue } switch v.Type { case "string": - argMap[k] = args.Fields[v.Name].GetStringValue() + if _, ok := pbArg.Kind.(*structpb.Value_StringValue); !ok { + return nil, nil, fmt.Errorf("argument %q must be a string", name) + } + argMap[k] = pbArg.GetStringValue() case "boolean": - argMap[k] = args.Fields[v.Name].GetBoolValue() + if _, ok := pbArg.Kind.(*structpb.Value_BoolValue); !ok { + return nil, nil, fmt.Errorf("argument %q must be a boolean", name) + } + argMap[k] = pbArg.GetBoolValue() case "number": - argMap[k] = args.Fields[v.Name].GetNumberValue() + if _, ok := pbArg.Kind.(*structpb.Value_NumberValue); !ok { + return nil, nil, fmt.Errorf("argument %q must be a number", name) + } + argMap[k] = int64(pbArg.GetNumberValue()) case "string_list": - argMap[k] = args.Fields[v.Name].GetListValue().Values + listVal := pbArg.GetListValue() + if listVal == nil { + if v.Required { + return nil, nil, fmt.Errorf("argument %q must be a list of strings", name) + } + continue + } + strs := make([]string, 0, len(listVal.Values)) + for _, item := range listVal.Values { + sv, ok := item.Kind.(*structpb.Value_StringValue) + if !ok { + return nil, nil, fmt.Errorf("argument %q must be a list of strings", name) + } + strs = append(strs, sv.StringValue) + } + argMap[k] = strs case "string_map": - argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() + sv := pbArg.GetStructValue() + if sv == nil { + if v.Required { + return nil, nil, fmt.Errorf("argument %q must be a string map", name) + } + continue + } + argMap[k] = sv.AsMap() default: return nil, nil, fmt.Errorf("unsupported argument type: %s", v.Type) } }Based on learnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/connector/action.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Error handling: usefmt.Errorfwith contextual messages; check specific errors witherrors.Is
Organize imports: standard library first, then third-party, then project imports; alphabetize within each group
Naming: CamelCase for exported identifiers; camelCase for unexported; preserve acronyms like ID, URL, HTTP, API
Limit line length to a maximum of 200 characters
Comments for exported items must be complete sentences ending with periods
Do not uselog.Fatalorlog.Panic(ruleguard-enforced)
Files:
pkg/connector/action.go
🧬 Code graph analysis (1)
pkg/connector/action.go (3)
pkg/connector/connector.go (1)
Connector(18-23)pkg/bsql/config.go (1)
ActionConfig(412-422)pkg/bsql/sql_syncer.go (1)
NewActionSyncer(62-70)
🔇 Additional comments (2)
pkg/connector/action.go (2)
148-148: Stop logging full action configuration.Line 148 still logs
actionCfgwithzap.Any, which can include SQL text, defaults, and other sensitive data. This was flagged earlier and remains unresolved—please log only safe metadata (e.g., key and high-level type).- l.Info("registered action", zap.String("action", actionKey), zap.Any("actionCfg", actionCfg)) + l.Info("registered action", zap.String("action", actionKey), zap.Strings("action_types", actionCfg.ActionType))
154-157: Redact action handler debug log.The debug statement still dumps the entire config, schema, and raw args, leaking SQL and user input into logs. This mirrors the previously raised concern; trim it down to safe identifiers before we ship.
- l.Debug("actionHandler", zap.Any("actionCfg", actionCfg), zap.Any("actionSchema", actionSchema), zap.Any("args", args)) + l.Debug("actionHandler", zap.String("action", actionCfg.Name), zap.Int("argument_count", len(actionCfg.Arguments)))
| var argMap = make(map[string]any) | ||
| for k, v := range actionCfg.Arguments { | ||
| if _, ok := args.Fields[v.Name]; !ok { | ||
| if v.Required { | ||
| return nil, nil, fmt.Errorf("argument %s is required", v.Name) | ||
| } | ||
| if v.Default != nil { | ||
| argMap[k] = v.Default | ||
| } | ||
| continue | ||
| } | ||
| switch v.Type { | ||
| case "string": | ||
| argMap[k] = args.Fields[v.Name].GetStringValue() | ||
| case "boolean": | ||
| argMap[k] = args.Fields[v.Name].GetBoolValue() | ||
| case "number": | ||
| argMap[k] = args.Fields[v.Name].GetNumberValue() | ||
| case "string_list": | ||
| argMap[k] = args.Fields[v.Name].GetListValue().Values | ||
| case "string_map": | ||
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() | ||
| default: | ||
| return nil, nil, fmt.Errorf("unsupported argument type: %s", v.Type) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent nil-arg panic in action handler.
Line 165 dereferences args without ensuring it’s non-nil. When an action is invoked without a payload, Baton passes nil; calling args.Fields[...] then panics and crashes the worker. Guard the struct before reading fields.
@@
- var argMap = make(map[string]any)
+ if args == nil {
+ args = &structpb.Struct{Fields: map[string]*structpb.Value{}}
+ }
+
+ var argMap = make(map[string]any)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| var argMap = make(map[string]any) | |
| for k, v := range actionCfg.Arguments { | |
| if _, ok := args.Fields[v.Name]; !ok { | |
| if v.Required { | |
| return nil, nil, fmt.Errorf("argument %s is required", v.Name) | |
| } | |
| if v.Default != nil { | |
| argMap[k] = v.Default | |
| } | |
| continue | |
| } | |
| switch v.Type { | |
| case "string": | |
| argMap[k] = args.Fields[v.Name].GetStringValue() | |
| case "boolean": | |
| argMap[k] = args.Fields[v.Name].GetBoolValue() | |
| case "number": | |
| argMap[k] = args.Fields[v.Name].GetNumberValue() | |
| case "string_list": | |
| argMap[k] = args.Fields[v.Name].GetListValue().Values | |
| case "string_map": | |
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() | |
| default: | |
| return nil, nil, fmt.Errorf("unsupported argument type: %s", v.Type) | |
| } | |
| } | |
| // Guard against nil args to avoid panic when Baton invokes the action without a payload. | |
| if args == nil { | |
| args = &structpb.Struct{Fields: map[string]*structpb.Value{}} | |
| } | |
| var argMap = make(map[string]any) | |
| for k, v := range actionCfg.Arguments { | |
| if _, ok := args.Fields[v.Name]; !ok { | |
| if v.Required { | |
| return nil, nil, fmt.Errorf("argument %s is required", v.Name) | |
| } | |
| if v.Default != nil { | |
| argMap[k] = v.Default | |
| } | |
| continue | |
| } | |
| switch v.Type { | |
| case "string": | |
| argMap[k] = args.Fields[v.Name].GetStringValue() | |
| case "boolean": | |
| argMap[k] = args.Fields[v.Name].GetBoolValue() | |
| case "number": | |
| argMap[k] = args.Fields[v.Name].GetNumberValue() | |
| case "string_list": | |
| argMap[k] = args.Fields[v.Name].GetListValue().Values | |
| case "string_map": | |
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() | |
| default: | |
| return nil, nil, fmt.Errorf("unsupported argument type: %s", v.Type) | |
| } | |
| } |
🤖 Prompt for AI Agents
In pkg/connector/action.go around lines 163 to 188, the code dereferences args
and args.Fields without guarding for nil, which panics when actions are invoked
with no payload; update the logic to first treat args as optional by checking if
args != nil and args.Fields != nil (or initialize a local empty map variable
when nil) before accessing args.Fields, then use that safe map for lookups and
value extraction so required/default handling still works without causing a
nil-pointer dereference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/connector/action.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Error handling: usefmt.Errorfwith contextual messages; check specific errors witherrors.Is
Organize imports: standard library first, then third-party, then project imports; alphabetize within each group
Naming: CamelCase for exported identifiers; camelCase for unexported; preserve acronyms like ID, URL, HTTP, API
Limit line length to a maximum of 200 characters
Comments for exported items must be complete sentences ending with periods
Do not uselog.Fatalorlog.Panic(ruleguard-enforced)
Files:
pkg/connector/action.go
🧬 Code graph analysis (1)
pkg/connector/action.go (3)
pkg/connector/connector.go (1)
Connector(18-23)pkg/bsql/config.go (1)
ActionConfig(412-422)pkg/bsql/sql_syncer.go (1)
NewActionSyncer(62-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cursor Bugbot
🔇 Additional comments (1)
pkg/connector/action.go (1)
162-187: Handle nil action args before dereferencing.When Baton invokes an action without a payload, it passes
nilforargs. Dereferencingargs.Fieldson Line 165 panics and crashes the connector. Initialize an empty struct/map before the loop so we can safely treat missing payloads as empty input.- var argMap = make(map[string]any) - for k, v := range actionCfg.Arguments { - if _, ok := args.Fields[v.Name]; !ok { + if args == nil { + args = &structpb.Struct{Fields: map[string]*structpb.Value{}} + } else if args.Fields == nil { + args.Fields = map[string]*structpb.Value{} + } + + var argMap = make(map[string]any) + for k, v := range actionCfg.Arguments { + if _, ok := args.Fields[v.Name]; !ok {
| stringMapField := &config_sdk.StringMapField{} | ||
| switch v := defaultValue.(type) { | ||
| case nil: | ||
| case map[string]*anypb.Any: | ||
| stringMapField.DefaultValue = v | ||
| default: | ||
| return nil, fmt.Errorf("invalid string map default for %s: %T", actionKey, defaultValue) | ||
| } | ||
| arg.Field = &config_sdk.Field_StringMapField{StringMapField: stringMapField} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accept plain Go maps for string_map defaults.
Config authors naturally supply defaults as map[string]string (or map[string]any) in YAML/JSON. The current type assertion only allows map[string]*anypb.Any, so any real-world default triggers the “invalid string map default” error and blocks action registration. Convert common Go map inputs into the proto-backed map instead of rejecting them.
case "string_map":
stringMapField := &config_sdk.StringMapField{}
switch v := defaultValue.(type) {
case nil:
case map[string]*anypb.Any:
stringMapField.DefaultValue = v
+ case map[string]string:
+ out := make(map[string]*anypb.Any, len(v))
+ for key, value := range v {
+ pbValue := structpb.NewStringValue(value)
+ pbAny, err := anypb.New(pbValue)
+ if err != nil {
+ return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err)
+ }
+ out[key] = pbAny
+ }
+ stringMapField.DefaultValue = out
+ case map[string]any:
+ out := make(map[string]*anypb.Any, len(v))
+ for key, value := range v {
+ pbValue, err := structpb.NewValue(value)
+ if err != nil {
+ return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err)
+ }
+ pbAny, err := anypb.New(pbValue)
+ if err != nil {
+ return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err)
+ }
+ out[key] = pbAny
+ }
+ stringMapField.DefaultValue = out
default:
return nil, fmt.Errorf("invalid string map default for %s: %T", actionKey, defaultValue)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| stringMapField := &config_sdk.StringMapField{} | |
| switch v := defaultValue.(type) { | |
| case nil: | |
| case map[string]*anypb.Any: | |
| stringMapField.DefaultValue = v | |
| default: | |
| return nil, fmt.Errorf("invalid string map default for %s: %T", actionKey, defaultValue) | |
| } | |
| arg.Field = &config_sdk.Field_StringMapField{StringMapField: stringMapField} | |
| case "string_map": | |
| stringMapField := &config_sdk.StringMapField{} | |
| switch v := defaultValue.(type) { | |
| case nil: | |
| case map[string]*anypb.Any: | |
| stringMapField.DefaultValue = v | |
| case map[string]string: | |
| out := make(map[string]*anypb.Any, len(v)) | |
| for key, value := range v { | |
| pbValue := structpb.NewStringValue(value) | |
| pbAny, err := anypb.New(pbValue) | |
| if err != nil { | |
| return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err) | |
| } | |
| out[key] = pbAny | |
| } | |
| stringMapField.DefaultValue = out | |
| case map[string]any: | |
| out := make(map[string]*anypb.Any, len(v)) | |
| for key, value := range v { | |
| pbValue, err := structpb.NewValue(value) | |
| if err != nil { | |
| return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err) | |
| } | |
| pbAny, err := anypb.New(pbValue) | |
| if err != nil { | |
| return nil, fmt.Errorf("invalid string map default for %s: %w", actionKey, err) | |
| } | |
| out[key] = pbAny | |
| } | |
| stringMapField.DefaultValue = out | |
| default: | |
| return nil, fmt.Errorf("invalid string map default for %s: %T", actionKey, defaultValue) | |
| } | |
| arg.Field = &config_sdk.Field_StringMapField{StringMapField: stringMapField} |
🤖 Prompt for AI Agents
In pkg/connector/action.go around lines 121 to 129, the string_map default
handling currently only accepts map[string]*anypb.Any and returns an error for
common Go maps; update the logic to accept map[string]*anypb.Any,
map[string]string and map[string]any (and nil) by converting non-proto maps into
the required map[string]*anypb.Any: create a new config_sdk.StringMapField, if
defaultValue is nil leave DefaultValue nil, if it's map[string]*anypb.Any assign
directly, if it's map[string]string or map[string]any iterate entries, convert
each value to an *anypb.Any (use proto/any helper like anypb.New on proto
messages or marshal non-proto values to protobuf Any via jsonpb/marshal-to-Any
or encoding into a suitable protobuf representation), handle conversion errors
by returning a descriptive fmt.Errorf, then set arg.Field =
&config_sdk.Field_StringMapField{StringMapField: stringMapField}.
| switch v.Type { | ||
| case "string": | ||
| argMap[k] = args.Fields[v.Name].GetStringValue() | ||
| case "boolean": | ||
| argMap[k] = args.Fields[v.Name].GetBoolValue() | ||
| case "number": | ||
| argMap[k] = args.Fields[v.Name].GetNumberValue() | ||
| case "string_list": | ||
| argMap[k] = args.Fields[v.Name].GetListValue().Values | ||
| case "string_map": | ||
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize string_list inputs to Go strings.
GetListValue().Values returns []*structpb.Value, so downstream CEL/SQL templating receives protobuf wrappers instead of the plain []string the config advertises. That breaks every action argument of type string_list. Convert the payload to a slice of Go strings before storing it in argMap.
- case "string_list":
- argMap[k] = args.Fields[v.Name].GetListValue().Values
+ case "string_list":
+ listValue := args.Fields[v.Name].GetListValue()
+ if listValue == nil {
+ return nil, nil, fmt.Errorf("argument %s must be a list of strings", v.Name)
+ }
+ values := listValue.GetValues()
+ items := make([]string, len(values))
+ for i, item := range values {
+ items[i] = item.GetStringValue()
+ }
+ argMap[k] = items📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| switch v.Type { | |
| case "string": | |
| argMap[k] = args.Fields[v.Name].GetStringValue() | |
| case "boolean": | |
| argMap[k] = args.Fields[v.Name].GetBoolValue() | |
| case "number": | |
| argMap[k] = args.Fields[v.Name].GetNumberValue() | |
| case "string_list": | |
| argMap[k] = args.Fields[v.Name].GetListValue().Values | |
| case "string_map": | |
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() | |
| switch v.Type { | |
| case "string": | |
| argMap[k] = args.Fields[v.Name].GetStringValue() | |
| case "boolean": | |
| argMap[k] = args.Fields[v.Name].GetBoolValue() | |
| case "number": | |
| argMap[k] = args.Fields[v.Name].GetNumberValue() | |
| case "string_list": | |
| listValue := args.Fields[v.Name].GetListValue() | |
| if listValue == nil { | |
| return nil, nil, fmt.Errorf("argument %s must be a list of strings", v.Name) | |
| } | |
| values := listValue.GetValues() | |
| items := make([]string, len(values)) | |
| for i, item := range values { | |
| items[i] = item.GetStringValue() | |
| } | |
| argMap[k] = items | |
| case "string_map": | |
| argMap[k] = args.Fields[v.Name].GetStructValue().AsMap() | |
| } |
🤖 Prompt for AI Agents
In pkg/connector/action.go around lines 173 to 183, the current case for
"string_list" assigns args.Fields[v.Name].GetListValue().Values (a
[]*structpb.Value) directly into argMap, which leaves protobuf Value wrappers
instead of plain Go strings; iterate the returned Values slice, extract each
element's string with GetStringValue() (or equivalent), collect them into a
[]string, and store that []string in argMap under the same key so downstream
CEL/SQL templating receives a plain []string as advertised.
… string list into a string list.
Description
Useful links:
Note
Adds a configurable connector actions framework with execution/validation, updates syncers and provisioning errors, and refreshes key dependencies.
pkg/connector/action.go, integrated inpkg/connector/connector.go).pkg/bsql/*.go).examples/postgres-test.yml.github.com/conductorone/baton-sdkto v0.4.6 incl.pkg/actions), migrates togithub.com/shirou/gopsutil/v4, updatestestifyto v1.11.1, addsgithub.com/ebitengine/purego, removesgo-m1cpu.Written by Cursor Bugbot for commit 585b60f. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Chores