Honor an explicit -c config path when -s is given - #11348
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesPortduino configuration flow
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/platform/portduino/PortduinoGlue.cpp (1)
334-336: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new comment block to two lines.
Keep only the non-obvious reason that
-smust not prevent YAML loading.As per coding guidelines, C++ comments must be one or two lines maximum and document only non-obvious rationale.
Proposed simplification
- // Load config YAML first (independent of simradio flag). - // The -s flag forces simradio mode but should NOT prevent config loading, - // since the YAML may contain non-radio settings (EnableUDP, display, etc.). + // Load YAML before applying -s so non-radio settings are preserved.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platform/portduino/PortduinoGlue.cpp` around lines 334 - 336, Shorten the comment above YAML configuration loading to two lines, retaining only the non-obvious rationale that the -s flag must not prevent loading non-radio settings from the YAML. Remove the redundant statement that config loading is independent of the simradio flag.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/platform/portduino/PortduinoGlue.cpp`:
- Around line 369-373: Move the force_simradio override block using
portduino_config.force_simradio and portduino_config.lora_module until after the
ConfigDirectory loading loop in loadConfig(), but before validation and
emit_yaml(). This ensures directory-based Lora.Module values cannot overwrite
the -s selection.
---
Nitpick comments:
In `@src/platform/portduino/PortduinoGlue.cpp`:
- Around line 334-336: Shorten the comment above YAML configuration loading to
two lines, retaining only the non-obvious rationale that the -s flag must not
prevent loading non-radio settings from the YAML. Remove the redundant statement
that config loading is independent of the simradio flag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6151ef0b-1f5f-4c5a-9479-768c86e515d9
📒 Files selected for processing (1)
src/platform/portduino/PortduinoGlue.cpp
8c6c24f to
47972b2
Compare
|
Thanks @coderabbitai — good catch, this one was real and I introduced it. Fixed in 47972b2.
Worth noting this was not reachable before this PR: The override now runs after the directory loop and before |
|
Tip For best results, initiate chat on the files or code changes.
All YAML sources now load before 🐇 ✅ ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
47972b2 to
2e4ff91
Compare
|
Nitpick applied in 2e4ff91 — and it was right on both counts.
// Load the YAML before applying -s: it also carries non-radio settings
// (EnableUDP, display, GPIO) that have to survive simulated mode.
// Applied after every config source: ConfigDirectory entries can set Lora.Module
// too, and -s must win over all of them, including in --check / --output-yaml.Both are two lines and keep only the non-obvious why. |
|
I meant to comment on this earlier, but this is actually intended behavior. The -s flag is for simulator use, in which case we really don't want to auto-load yaml. I do agree that the -c flag should be honored. |
2e4ff91 to
95f0165
Compare
|
@jp-bennett thanks — that reframes the PR, so let me check which shape you want before I push anything. I take your point that if (portduino_config.force_simradio == true) {
portduino_config.lora_module = use_simradio;
} else if (configPath != nullptr) {
// -c handled here, never reached when -s is setSo What brought me here: a simulated node with The narrow version is roughly this — explicit if (configPath != nullptr) {
// an explicit -c is honored even in simulated mode
...
} else if (portduino_config.force_simradio) {
// -s with no -c: do not go looking for a config
} else if (access("config.yaml", R_OK) == 0) {
...The Two questions:
@caveman99 — you rebased this branch onto |
|
@matutetandil i fast-forwarded the underlying fork so it doesn't drift too much from develop head. That operationw as not an approval or a rejection, i stand with @jp-bennett assessment. read and parse the -c flag, then if -s is specified force the simradio on. |
The simradio flag (-s) is the first branch of an if/else-if chain that also handles config loading, so it short-circuits every later branch -- including the one for an explicit -c <path>. Skipping config discovery under -s is intended, but a config path the user passed by hand is not discovery, and it is silently ignored today. Move the -s check after the -c branch so an explicit path is always parsed, and skip only the implicit discovery (./config.yaml, /etc/meshtasticd/config.yaml) when -s is given without -c. The radio override then runs after every config source, since -c and its ConfigDirectory entries can both set Lora.Module and -s has to win over them. Doing it there also fixes --check and --output-yaml, which reported the configured module rather than the simulated one because the old override sat behind an early return. Behaviour with a bare -s is unchanged: no YAML is loaded and the radio is the simulator.
95f0165 to
d451638
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Reworked exactly as asked, @caveman99 — thanks for the call, and for the fast-forward.
if (configPath != nullptr) {
// explicit -c: always parsed, including under -s
} else if (portduino_config.force_simradio) {
// -s with no -c: the simulator brings its own defaults, so skip config discovery.
} else if (access("config.yaml", R_OK) == 0) {@jp-bennett's point holds in full: a bare The radio override stays after all config sources, since Checked against the built binary rather than by reading:
Row 1 is the one that matters for your and @jp-bennett's position: the local Rebased onto current |
Reworked per @jp-bennett's and @caveman99's read:
-sshould keep auto-loading off, but an explicit-cshould still be honored.In
portduinoSetup()the simradio flag is the first branch of the chain that also handles config loading:Because
-sshort-circuits the whole chain, it swallows the-cbranch along with the discovery ones. Skipping discovery is the intent; dropping a path the user typed by hand is not, and it happens with no warning — the file exists, the path is right, the daemon starts fine, the settings just never take effect.This moves the
-scheck to sit after the-cbranch instead of before it:so an explicit path is always parsed, and only the implicit discovery (
./config.yaml,/etc/meshtasticd/config.yaml) is skipped under a bare-s.The radio override then runs after every config source, because
-cand theConfigDirectoryentries it can pull in are both able to setLora.Module, and-shas to win over all of them. Putting it there also fixes--checkand--output-yaml, which used to report the configured module rather than the simulated one, since the old override sat behind an early return.ConfigDirectoryneeds no special case: it follows whatever config was actually loaded, so a bare-sleaves it empty and the loop does not run.Verified against the built binary
Lora.ModuleMaxNodes-s(with a./config.yamlpresent)sim-s -c custom.yamlcustom.yamlsim-c)-c custom.yamlcustom.yamlsx1262./config.yamlsx1268--checkagrees: bare-sreports "No configuration files were found",-s -c custom.yamllistscustom.yamland reportsModule: sim.pio run -e nativeSUCCESS, clang-format clean.Found while running two simulated nodes with
EnableUDPfor multicast discovery — the setting was ignored purely because-swas also passed.Split out of #9749.
Summary by CodeRabbit