Skip to content

fix: add validation and sanitization for logistics config fields#398

Merged
Indemnity83 merged 1 commit into
mc/26.1from
fix-runtime-config-validation
May 30, 2026
Merged

fix: add validation and sanitization for logistics config fields#398
Indemnity83 merged 1 commit into
mc/26.1from
fix-runtime-config-validation

Conversation

@Indemnity83
Copy link
Copy Markdown
Owner

Summary

This update introduces enhanced validation logic for logistics configuration parameters, ensuring that settings adhere to defined constraints and improving the robustness of the configuration handling. This change is crucial for preventing runtime errors that could arise from invalid configuration values.

Changes

  • Validation and Sanitization Logic:

    • Added comprehensive validation for various logistics configuration parameters, including limits on speed, energy, and outputs.
    • Introduced sanitization methods to replace invalid configuration values with sensible defaults, ensuring the application remains stable.
  • Error Messaging:

    • Improved error handling with descriptive messages when configuration values do not meet the expected criteria, facilitating easier debugging.
  • Unit Tests:

    • Implemented extensive unit tests to verify the correctness of the new validation logic, ensuring resilience against invalid configurations.
    • Tests cover scenarios such as rejection of invalid values, boundary condition acceptance, and sanitization of configuration fields.

Notes

  • Ensure that existing configurations are reviewed post-update, as the added validation could lead to previously accepted values being rejected.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a4c97f21-6ed2-41f2-846a-5297647bdd45

📥 Commits

Reviewing files that changed from the base of the PR and between 159df97 and eaf4ef4.

📒 Files selected for processing (2)
  • common/src/main/java/com/logistics/core/LogisticsConfig.java
  • common/src/test/java/com/logistics/core/LogisticsConfigTest.java

📝 Walkthrough

Walkthrough

This PR extends LogisticsConfig with validation and sanitization capabilities. The ConfigEntry record is enhanced with a validator field. The command registry (ENTRIES) is updated so each quarry, pipe, and engine setting registers both a parser and validator enforcing numeric bounds, finiteness, and cross-field constraints. Configuration loading now sanitizes inputs by validating fields, replacing invalid values with defaults while logging warnings, and normalizing interdependent ranges. A new test suite validates the enforcement of these constraints and the sanitization behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main changes: adding validation and sanitization for logistics config fields, which aligns with the core modifications in the changeset.
Description check ✅ Passed The description is directly related to the changeset, covering validation logic, sanitization methods, error handling, and test coverage—all aspects present in the code changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-runtime-config-validation

Comment @coderabbitai help to get the list of available commands and usage tips.

@Indemnity83 Indemnity83 merged commit f5cd45a into mc/26.1 May 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant