-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix database configuration parsing for string representations of arrays #3275
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
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: fiftin <[email protected]>
Co-authored-by: fiftin <[email protected]>
@copilot read how user solved the issue:
Your solution is incorrect. |
Co-authored-by: fiftin <[email protected]>
... You're absolutely right - my previous solution was incorrect. I was only fixing the error message instead of addressing the root cause. I've now implemented the proper fix by updating the This addresses the actual problem you identified where the database contained string representations of arrays that needed to be parsed, rather than just improving error messages. Fixed in commit 3ff95e6. |
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.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
res = arr | ||
ok = true | ||
} | ||
} |
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.
Bug: Slice Unmarshalling Fails for Non-String Types
The CastValueToKind
function's reflect.Slice
case always unmarshals string representations into a []string
. This leads to a type mismatch panic when assigning to configuration fields expecting slices with different element types (e.g., []int
, []bool
), as reflect.Kind
lacks the necessary element type information.
This PR fixes a panic that occurs during Semaphore startup when database configuration contains string representations of arrays that need to be converted to slice types.
Problem
When upgrading from v2.15.0 to v2.16.10, users with certain database configurations would encounter a panic during startup. The issue occurred when the database contained configuration values stored as string representations of JSON arrays (e.g.,
["-u semaphore -b"]
) that needed to be assigned to slice fields in the configuration struct.The
CastValueToKind
function inutil/config.go
only handled basic types (string
,int
,bool
) but did not support converting string representations of arrays to actual Go slices, causing the application to fail during configuration loading.Root Cause
The
CastValueToKind
function lacked support forreflect.Slice
type conversion. When database configuration contained values like:apps.ansible.args
["-u semaphore -b"]
(stored as string)The function could not convert this string representation to the expected
[]string
type, resulting in a panic.Solution
Extended the
CastValueToKind
function to handle slice type conversion by adding JSON parsing support:Result
Before: Application panics during startup when encountering string representations of arrays in database configuration.
After: Application gracefully converts string representations like
["-u semaphore -b"]
to proper Go slices ([]string{""-u semaphore -b"}
), allowing normal startup to continue.This fix ensures backward compatibility with existing database configurations while properly handling type conversions that may occur during database migrations or manual configuration changes.
Fixes #3203.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.