feat: make web server bind address configurable via .wflcfg - #253
Conversation
Add web_server_bind_address configuration option to allow configuring which IP address the web server binds to. This enables users to: - Keep the default localhost binding (127.0.0.1) for local development - Bind to all interfaces (0.0.0.0) for external access - Bind to specific network interfaces as needed Changes: - Add web_server_bind_address field to WflConfig struct - Add config parsing for the new setting in parse_config_text - Update interpreter to use the configured bind address - Update .wflcfg example with the new option and documentation Co-Authored-By: Bradley Byrd <bsbyrd@logbie.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis pull request introduces a configurable web server bind address feature. The configuration option is added to the schema, documented comprehensively, parsed in the config module, and integrated into the server initialization to replace the hard-coded localhost binding. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Claude finished @devin-ai-integration[bot]'s task —— View job PR Review CompleteI've thoroughly reviewed the implementation of configurable web server bind address. Here's my comprehensive feedback: Code Quality and Best Practices ✅Positive aspects:
Areas for improvement:
Potential Bugs and Issues
|
Add detailed documentation for all WFL configuration options including: - General runtime settings (timeout, logging, debug reports) - Execution logging settings - Code quality/linter settings - Security settings (shell execution, allowlists) - Subprocess resource management - Web server settings (including new bind address option) Also includes example configurations for development and production use. Co-Authored-By: Bradley Byrd <bsbyrd@logbie.com>
|
Claude finished @devin-ai-integration[bot]'s task —— View job PR Review: Configurable Web Server Bind AddressI've conducted a comprehensive review of this pull request that adds configurable web server bind address functionality. Review Tasks:
Code Quality and Best Practices ✅Positive aspects:
Minor improvement opportunities:
Potential Bugs and Issues
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/interpreter/mod.rs (1)
4063-4080: Make bind-address parsing a bit more robust (trim + better error + IPv6 hint).
Right now a value like" 127.0.0.1 "would fail, and the error message implies IPv4-only examples even thoughIpAddrsupports IPv6.Proposed patch
- let bind_addr: IpAddr = match self.config.web_server_bind_address.parse() { - Ok(addr) => addr, - Err(_) => { - return Err(RuntimeError::new( - format!( - "Invalid web_server_bind_address in config: '{}'. Expected a valid IP address (e.g., '127.0.0.1' or '0.0.0.0')", - self.config.web_server_bind_address - ), - *line, - *column, - )); - } - }; + let bind_addr_raw = self.config.web_server_bind_address.trim(); + let bind_addr: IpAddr = bind_addr_raw.parse().map_err(|e| { + RuntimeError::new( + format!( + "Invalid web_server_bind_address in config: '{bind_addr_raw}'. Expected a valid IP address (e.g., '127.0.0.1', '0.0.0.0', or '::1'): {e}" + ), + *line, + *column, + ) + })?;src/config.rs (2)
549-570: Unnecessary clone on line 563.The variable
addris only used in the debug log after assignment and could be moved instead of cloned.Suggested improvement
if !addr.is_empty() { if config.web_server_bind_address != WflConfig::default().web_server_bind_address { log::debug!( "Overriding web_server_bind_address: {} -> {} from {}", config.web_server_bind_address, addr, file.display() ); } - config.web_server_bind_address = addr.clone(); + config.web_server_bind_address = addr; log::debug!( "Loaded web_server_bind_address: {} from {}", - addr, + config.web_server_bind_address, file.display() ); }
549-570: Consider validating the IP address format during config loading with a warning.The
web_server_bind_addresssilently accepts any string during configuration parsing (lines 549-570) and defers validation to runtime when the server starts. This differs fromshell_execution_mode(lines 454-478), which validates during config load, logs a warning, and falls back to the default for invalid values.While the interpreter does provide a clear error message at runtime ("Invalid web_server_bind_address in config: '{}'. Expected a valid IP address (e.g., '127.0.0.1' or '0.0.0.0')"), validating and warning during config loading would improve user experience by catching configuration errors earlier, consistent with other security-sensitive settings.
Suggested validation with early warning and fallback
"web_server_bind_address" => { let addr = value.trim().to_string(); if !addr.is_empty() { + // Validate IP address format early + if addr.parse::<std::net::IpAddr>().is_err() { + log::warn!( + "Invalid web_server_bind_address '{}' in {}, using default", + addr, + file.display() + ); + continue; + } if config.web_server_bind_address != WflConfig::default().web_server_bind_addressDocs/reference/configuration-reference.md (1)
22-26: Add language specifier to fenced code block.The static analysis tool flagged this code block as missing a language specifier. For directory structures, use
textorplaintext.Suggested fix
-``` +```text my-project/ main.wfl .wflcfg # Local configuration for this project</details> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 76d0be945342ab00544f4f4d9456c36b67a87e99 and b6c12ca0d90a95351dff9ef2bdd38c3aa22e7260. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `.wflcfg` * `Docs/reference/configuration-reference.md` * `src/config.rs` * `src/interpreter/mod.rs` </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (3)</summary> <details> <summary>**/*.rs</summary> **📄 CodeRabbit inference engine (CLAUDE.md)** > `**/*.rs`: Use snake_case for function and file names > Use CamelCase for type and trait names > Use SCREAMING_SNAKE_CASE for constants > Format all Rust code using cargo fmt with .rustfmt.toml configuration > Run cargo clippy with all targets and features with -D warnings flag to enforce linting > > `**/*.rs`: Use snake_case naming convention for functions and file names > Use CamelCase naming convention for types and traits > Use SCREAMING_SNAKE_CASE naming convention for constants > Format all Rust code using `cargo fmt --all` as configured in `.rustfmt.toml` > Ensure all code passes `cargo clippy --all-targets --all-features -- -D warnings` linting checks > Never break backward compatibility with existing WFL programs; all TestPrograms/ must pass after any changes > Review SECURITY.md for security considerations; avoid logging secrets and use zeroization for sensitive data Files: - `src/config.rs` - `src/interpreter/mod.rs` </details> <details> <summary>Docs/**/*.md</summary> **📄 CodeRabbit inference engine (CLAUDE.md)** > ALL code examples in documentation MUST be validated with MCP tools before adding to Docs/ > > `Docs/**/*.md`: Organize documentation in 6 sections (Introduction, Getting Started, Language Basics, Advanced Features, Standard Library, Best Practices) following `Docs/wfl-documentation-policy.md` and 19 principles in `Docs/wfl-foundation.md` > Validate ALL code examples in documentation using MCP tools (`mcp__wfl-lsp__parse_wfl`, `mcp__wfl-lsp__analyze_wfl`, `mcp__wfl-lsp__typecheck_wfl`, `mcp__wfl-lsp__lint_wfl`) before adding to docs > Use proper WFL syntax in documentation: conditionals with NESTED blocks (`otherwise: check if`, NOT `otherwise check if`), list push syntax (`push with <list> and <value>`, NOT `push to`), loop variable as `count` in count loops, typeof syntax as `typeof of value` NOT `typeof(value)`, action syntax as `define action called name with parameters x:` NOT `action name with x:` > Avoid using reserved WFL keywords (60+ keywords including: is, file, add, current, etc.) without underscores in user-defined identifiers; use snake_case variants like `is_active`, `myfile` Files: - `Docs/reference/configuration-reference.md` </details> <details> <summary>src/interpreter/**/*.rs</summary> **📄 CodeRabbit inference engine (CLAUDE.md)** > `src/interpreter/**/*.rs`: Interpreter must be async-capable using Tokio runtime and include subprocess handling with security sanitization > Web server support must be integrated via the warp crate with HTTP request/response handling > > Implement async-capable direct AST execution using Tokio runtime, with subprocess handling featuring security sanitization and web server support via warp integration for HTTP request/response handling Files: - `src/interpreter/mod.rs` </details> </details><details> <summary>🧠 Learnings (2)</summary> <details> <summary>📚 Learning: 2026-01-12T16:06:33.931Z</summary>Learnt from: CR
Repo: WebFirstLanguage/wfl PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T16:06:33.931Z
Learning: Applies to src/interpreter/**/*.rs : Web server support must be integrated via the warp crate with HTTP request/response handling**Applied to files:** - `src/config.rs` - `src/interpreter/mod.rs` </details> <details> <summary>📚 Learning: 2026-01-12T16:07:01.897Z</summary>Learnt from: CR
Repo: WebFirstLanguage/wfl PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T16:07:01.897Z
Learning: Applies to src/interpreter/**/*.rs : Implement async-capable direct AST execution using Tokio runtime, with subprocess handling featuring security sanitization and web server support via warp integration for HTTP request/response handling**Applied to files:** - `src/interpreter/mod.rs` </details> </details><details> <summary>🧬 Code graph analysis (1)</summary> <details> <summary>src/interpreter/mod.rs (1)</summary><blockquote> <details> <summary>src/interpreter/error.rs (1)</summary> * `new` (25-32) </details> </blockquote></details> </details><details> <summary>🪛 markdownlint-cli2 (0.18.1)</summary> <details> <summary>Docs/reference/configuration-reference.md</summary> 22-22: Fenced code blocks should have a language specified (MD040, fenced-code-language) </details> </details> </details> <details> <summary>🔇 Additional comments (7)</summary><blockquote> <details> <summary>src/interpreter/mod.rs (1)</summary><blockquote> `49-49`: **Good, minimal import for the new feature.** </blockquote></details> <details> <summary>.wflcfg (1)</summary><blockquote> `6-9`: **Config parsing for `web_server_bind_address` is correct.** The parser trims values (line 551) and uses Rust's `std::net::IpAddr::parse()` to validate the address, which correctly handles both IPv4 and IPv6 formats without requiring quotes. IPv6 addresses like `::1` work as-is. No changes needed. </blockquote></details> <details> <summary>src/config.rs (2)</summary><blockquote> `42-43`: **LGTM - Secure default with appropriate type.** The new field follows the existing patterns in the struct. Storing as `String` defers IP validation to the interpreter, which allows for more detailed error messages at startup time. --- `116-117`: **LGTM - Secure default value.** Defaulting to `127.0.0.1` ensures the web server only listens on localhost by default, which is the secure choice. </blockquote></details> <details> <summary>Docs/reference/configuration-reference.md (3)</summary><blockquote> `233-252`: **Well-documented web server configuration with appropriate security note.** The documentation clearly explains the security implications of binding to `0.0.0.0` and provides helpful guidance on IPv4/IPv6 options. This aligns with the implementation default of `127.0.0.1`. --- `1-340`: **Comprehensive and accurate configuration documentation.** The documentation is well-structured, all default values match the implementation in `src/config.rs`, and the example configurations provide practical guidance for development vs. production use cases. --- `205-231`: **The documentation is complete as-is. The four additional fields in `SubprocessConfig` are internal implementation details that are not user-configurable and therefore do not require documentation.** The configuration file parsing in `src/config.rs` only deserializes three subprocess fields: `max_concurrent_processes`, `max_buffer_size_bytes`, and `kill_on_shutdown`. The other four fields (`enable_auto_cleanup`, `enable_reaper`, `reaper_interval_secs`, `warn_on_orphan`) appear only in the struct definition and Default implementation, with no corresponding parsing code. This indicates they are internal-only settings, not exposed to users for configuration. > Likely an incorrect or invalid review comment. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
|
Test Coverage ❌ Critical gap - Missing tests: No config parsing tests: No tests verify that web_server_bind_address is properly parsed from config files #[cfg(test)] #[tokio::test] |
Add unit tests in config.rs for: - Default value (127.0.0.1) - Custom IPv4 addresses (0.0.0.0, 192.168.1.100) - IPv6 addresses (::1) - Local config overriding global config - Empty value handling (keeps default) Add integration tests in web_server_bind_address_test.rs for: - Server binding to localhost by default - Server binding to all interfaces (0.0.0.0) - Server failing with invalid bind address - Server binding to IPv6 localhost Co-Authored-By: Bradley Byrd <bsbyrd@logbie.com>
|
Claude finished @devin-ai-integration[bot]'s task —— View job PR Review: Configurable Web Server Bind AddressReview Tasks:
✅ Excellent Improvement - Test Coverage AddedThis updated PR addresses the critical missing test coverage that was identified in previous reviews. The addition of Code Quality and Best Practices ✅Strong implementation with good practices:
Minor improvement opportunities:
Test Coverage ✅ Major ImprovementComprehensive test suite added:
Test quality highlights:
This addresses the most significant gap from the previous review. Security Considerations ✅Maintains secure defaults:
Performance Considerations ✅Minimal performance impact:
Potential Issues
|
|
Need to resolve merge conflicts |
Co-Authored-By: Bradley Byrd <bsbyrd@logbie.com>
|
Claude finished @devin-ai-integration[bot]'s task —— View job PR Review: Configurable Web Server Bind AddressReview Tasks:
✅ Overall Assessment: Strong Implementation with Excellent Test CoverageThis PR delivers a well-designed feature with comprehensive test coverage that addresses the critical gap identified in previous reviews. The implementation is production-ready and follows WFL's established patterns. Code Quality and Best Practices ✅Strengths:
Minor improvements:
Security Considerations ✅Secure by design:
Performance Considerations ✅Minimal performance impact:
Test Coverage ✅ Major ImprovementComprehensive test suite in
Test quality highlights:
This completely addresses the missing test coverage that was the primary concern in previous reviews. Implementation Quality AnalysisFile:
File:
File:
File:
Potential Edge Cases
|
Co-Authored-By: Bradley Byrd <bsbyrd@logbie.com>
|
Claude finished @devin-ai-integration[bot]'s task —— View job PR Review: Configurable Web Server Bind AddressReview Tasks:
✅ Overall Assessment: Strong Implementation with Excellent Test CoverageThis PR delivers a well-designed feature with comprehensive test coverage that addresses the critical gap identified in previous reviews. The implementation is production-ready and follows WFL's established patterns. Code Quality and Best Practices ✅Strengths:
Minor improvements:
Security Considerations ✅Secure by design:
Performance Considerations ✅Minimal performance impact:
Test Coverage ✅ Major ImprovementComprehensive test suite in
Test quality highlights:
This completely addresses the missing test coverage that was the primary concern in previous reviews. Implementation Quality AnalysisFile:
File:
File:
File:
Potential Edge Cases
|
Summary
Makes the web server bind address configurable through the
.wflcfgconfiguration file instead of being hardcoded to127.0.0.1. This allows users to bind the web server to different interfaces (e.g.,0.0.0.0to listen on all interfaces for external access).Changes:
web_server_bind_addressfield toWflConfigstruct with default value127.0.0.1.wflcfgexample with documentationDocs/reference/configuration-reference.md)Updates since last revision
Added comprehensive test coverage for the
web_server_bind_addressconfiguration:Unit tests in
src/config.rs:Integration tests in
tests/web_server_bind_address_test.rs:Latest updates:
is_ok()+unwrap()pattern toif let Ok(...))parse_bind_address_to_ipv4helper function (usingIpAddr::parse()directly instead)Review & Testing Checklist for Human
0.0.0.0: Create a WFL script with a web server and setweb_server_bind_address = 0.0.0.0in.wflcfg, verify the server is accessible from another machine/containerweb_server_bind_address = not-an-ipand verify the error message is clearRecommended test plan:
Notes
Link to Devin run: https://app.devin.ai/sessions/cde13f488fc54349b1bec49461523f75
Requested by: Bradley Byrd (@logbie)