-
-
Notifications
You must be signed in to change notification settings - Fork 164
Sqlpage port variable parsing #1206
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: main
Are you sure you want to change the base?
Conversation
…t variables Co-authored-by: contact <contact@ophir.dev>
|
Cursor Agent can help with this pull request. Just |
lovasoa
left a 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.
@cursoragent do not deserialize the port as json
src/app_config.rs
Outdated
| let v: Option<serde_json::Value> = Deserialize::deserialize(deserializer)?; | ||
| match v { | ||
| Some(serde_json::Value::Number(n)) => { | ||
| if let Some(port) = n.as_u64() { | ||
| if port <= 65535 { | ||
| Ok(Some(port as u16)) |
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.
you can just try to deserialize as u16 directly
src/app_config.rs
Outdated
| Some(serde_json::Value::String(s)) => { | ||
| if let Ok(port) = s.parse::<u16>() { |
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.
do not reparse number
|
I have updated The implementation now:
This change is cleaner and more efficient as it avoids the overhead of the |
Co-authored-by: contact <contact@ophir.dev>
|
@cursoragent cargo clippy |
|
I have fixed the // Before
log::warn!("Ignoring invalid SQLPAGE_PORT value from Kubernetes: {}", v);
Err(E::custom(format!("Invalid port number: {}", v)))
// After
log::warn!("Ignoring invalid SQLPAGE_PORT value from Kubernetes: {v}");
Err(E::custom(format!("Invalid port number: {v}"))) |
Co-authored-by: contact <contact@ophir.dev>
Detect and ignore Kubernetes-injected
SQLPAGE_PORTURI values to prevent crashes during deployment.When deploying to Kubernetes, if a service named
sqlpageexists, Kubernetes automatically injects an environment variable likeSQLPAGE_PORT=tcp://10.0.0.11:8080. This URI format clashes with SQLPage's expectation of an integer port, causing the application to crash. This change adds a custom deserializer for theportconfiguration that detects this URI format, logs a warning, and ignores the value, allowing SQLPage to start correctly using its default port or other configured port.