-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: add support for JSON5/JSONC config files #2059
feat: add support for JSON5/JSONC config files #2059
Conversation
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.
PR Summary
This PR adds support for JSON5/JSONC configuration files across the Rivet platform, migrating from YAML while maintaining backward compatibility.
- Added JSON5/JSONC parsing in
packages/common/config/src/lib.rs
andpackages/edge/infra/client/manager/src/main.rs
with proper error handling - Converted configuration files from YAML to JSONC in
docker/dev-full/
directory while preserving functionality - Added
json5
v0.4.1 dependency to workspace and relevant packages for parsing JSON5/JSONC formats - Documentation paths in
site/src/content/docs/self-hosting/
show inconsistencies betweendocker/dev-full/
anddocker/monolith/
directories - Security concerns in new JSONC configs include hardcoded JWT keys, passwords, and disabled SSL marked for development use
16 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -76,7 +76,7 @@ services: | |||
vector-server: | |||
condition: service_started | |||
volumes: | |||
- ./rivet-edge-server:/etc/rivet-server:ro | |||
- ./rivet-edge-server/config.jsonc:/etc/rivet-server/config.jsonc:ro |
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.
logic: The volume mount path /etc/rivet-server/config.jsonc
is inconsistent with the service name rivet-edge-server
. This could cause configuration conflicts.
- ./rivet-edge-server/config.jsonc:/etc/rivet-server/config.jsonc:ro | |
- ./rivet-edge-server/config.jsonc:/etc/rivet-edge-server/config.jsonc:ro |
@@ -153,7 +153,7 @@ services: | |||
# TODO(RVT-4168): Compile libfdb from scratch for ARM | |||
platform: linux/amd64 | |||
restart: unless-stopped | |||
command: -c /etc/rivet-client/config.yaml | |||
command: -c /etc/rivet-client/config.jsonc |
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.
style: The command format differs from rivet-server (line 9). Consider using consistent command formats across services.
"jwt": { | ||
"public": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAx7S9ab9ErA50y0tVfFro919+BBxFSuwMKmcJ5QI853Y=\n-----END PUBLIC KEY-----\n", | ||
"private": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIDI+WHFytxvdtfGot36NMCI26s2Yp0+E5u9OiPf3NQX3\n-----END PRIVATE KEY-----\n" |
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.
logic: JWT private key should not be committed to the repository. Remove this and use environment variable as noted in the comment above.
"jwt": { | |
"public": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAx7S9ab9ErA50y0tVfFro919+BBxFSuwMKmcJ5QI853Y=\n-----END PUBLIC KEY-----\n", | |
"private": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIDI+WHFytxvdtfGot36NMCI26s2Yp0+E5u9OiPf3NQX3\n-----END PRIVATE KEY-----\n" | |
"jwt": { | |
"public": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAx7S9ab9ErA50y0tVfFro919+BBxFSuwMKmcJ5QI853Y=\n-----END PUBLIC KEY-----\n" |
"url": "redis://redis:6379", | ||
"password": "password" | ||
}, | ||
"persistent": { | ||
"url": "redis://redis:6379", | ||
"password": "password" | ||
} |
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.
style: Both Redis instances use same credentials and URL. Consider using separate passwords for ephemeral vs persistent Redis in development to catch connection errors.
"jwt": { | ||
"public": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAx7S9ab9ErA50y0tVfFro919+BBxFSuwMKmcJ5QI853Y=\n-----END PUBLIC KEY-----\n", | ||
"private": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIDI+WHFytxvdtfGot36NMCI26s2Yp0+E5u9OiPf3NQX3\n-----END PRIVATE KEY-----\n" |
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.
logic: The private JWT key is included in the config file despite the comment above explicitly stating not to include it. This is a security risk and contradicts the documentation. Remove the private key and use the environment variable as recommended.
@@ -70,7 +70,7 @@ fn add_source<P: AsRef<Path>>( | |||
let path = entry.path(); | |||
if path.is_file() { | |||
if let Some(extension) = path.extension().and_then(std::ffi::OsStr::to_str) { | |||
if ["json", "yaml", "yml"].contains(&extension) { | |||
if ["json", "json5", "jsonc", "yaml", "yml"].contains(&extension) { |
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.
style: Consider using a const array or HashSet for better maintainability of supported extensions
let value: serde_json::Value = json5::from_str(&content) | ||
.map_err(|e| global_error::GlobalError::new(e))?; | ||
let json = serde_json::to_string(&value) | ||
.map_err(|e| global_error::GlobalError::new(e))?; | ||
return Ok(settings.add_source(config_loader::File::from_str(&json, config_loader::FileFormat::Json))) |
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.
style: Consider adding error context about which file failed to parse. The current error only includes the parsing error but not the file path.
let value: serde_json::Value = json5::from_str(&content) | |
.map_err(|e| global_error::GlobalError::new(e))?; | |
let json = serde_json::to_string(&value) | |
.map_err(|e| global_error::GlobalError::new(e))?; | |
return Ok(settings.add_source(config_loader::File::from_str(&json, config_loader::FileFormat::Json))) | |
let value: serde_json::Value = json5::from_str(&content) | |
.map_err(|e| global_error::GlobalError::new_with_context(e, format!("failed to parse {}", path.display())))?; | |
let json = serde_json::to_string(&value) | |
.map_err(|e| global_error::GlobalError::new_with_context(e, format!("failed to serialize {}", path.display())))?; | |
return Ok(settings.add_source(config_loader::File::from_str(&json, config_loader::FileFormat::Json))) |
Some("json5") | Some("jsonc") => { | ||
// Parse JSON5/JSONC and convert to regular JSON | ||
let value: serde_json::Value = json5::from_str(&content) | ||
.map_err(|e| global_error::GlobalError::new(e))?; | ||
let json = serde_json::to_string(&value) | ||
.map_err(|e| global_error::GlobalError::new(e))?; | ||
return Ok(settings.add_source(config_loader::File::from_str(&json, config_loader::FileFormat::Json))) | ||
} |
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.
style: Early return here creates inconsistent control flow compared to other format handlers. Consider restructuring to use the same pattern as JSON and YAML handlers.
@@ -4,7 +4,7 @@ import Link from 'next/link'; | |||
|
|||
# Client Config | |||
|
|||
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-client/config.yaml'>`docker/monolith/rivet-client/config.yaml`</Link> | |||
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-client/config.jsonc'>`docker/monolith/rivet-client/config.jsonc`</Link> |
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.
logic: Link path and displayed path are inconsistent. Link points to 'dev-full' directory but text shows 'monolith' directory.
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-client/config.jsonc'>`docker/monolith/rivet-client/config.jsonc`</Link> | |
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-client/config.jsonc'>`docker/dev-full/rivet-client/config.jsonc`</Link> |
@@ -4,7 +4,7 @@ import Link from 'next/link'; | |||
|
|||
# Server Config | |||
|
|||
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-server/config.yaml'>`docker/monolith/rivet-server/config.yaml`</Link> | |||
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-server/config.jsonc'>`docker/monolith/rivet-server/config.jsonc`</Link> |
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.
logic: The href points to dev-full but the displayed path shows monolith - this inconsistency needs to be fixed
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-server/config.jsonc'>`docker/monolith/rivet-server/config.jsonc`</Link> | |
Default location: <Link href='https://github.com/rivet-gg/rivet/blob/main/docker/dev-full/rivet-server/config.jsonc'>`docker/dev-full/rivet-server/config.jsonc`</Link> |
7f6cbbe
to
22d17b8
Compare
52486f4
to
dc6cea5
Compare
22d17b8
to
b2c46c3
Compare
822cda3
to
7b83adc
Compare
7b83adc
to
4c23ff5
Compare
cf49442
to
2bc1dbc
Compare
2bc1dbc
to
cf49442
Compare
4c23ff5
to
7b83adc
Compare
7b83adc
to
4c23ff5
Compare
cf49442
to
2bc1dbc
Compare
2bc1dbc
to
cf49442
Compare
4c23ff5
to
7b83adc
Compare
7b83adc
to
4c23ff5
Compare
cf49442
to
2bc1dbc
Compare
Merge activity
|
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
Changes