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.
@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.
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.
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.