Skip to content

Implement comprehensive malformed config validation with detailed error reporting - #843

Open
Dekah101 wants to merge 1 commit into
BCPathway:mainfrom
Dekah101:main
Open

Implement comprehensive malformed config validation with detailed error reporting#843
Dekah101 wants to merge 1 commit into
BCPathway:mainfrom
Dekah101:main

Conversation

@Dekah101

@Dekah101 Dekah101 commented Aug 27, 2026

Copy link
Copy Markdown

Implement professional validation and error reporting for malformed .bc-forge.json configuration files. The CLI now rejects invalid configurations cleanly with specific, actionable error messages that guide users to fix their config issues.

What does this PR do?

Enhanced Configuration Validation:

  • Replaced generic error messages with detailed, context-specific validation errors
  • Implemented formatValidationErrors() helper to provide precise feedback for each validation failure
  • Errors now include field names, expected values, and actual values provided by users
  • Comprehensive error handling for:
    • Type mismatches (e.g., string instead of integer)
    • Pattern violations (invalid Stellar addresses, secret keys)
    • Range violations (decimals outside 0-18 range)
    • Enum validation (invalid network values)
    • Required field checks

Improved Error Reporting:

  • Enhanced config loading with descriptive warning messages
  • All validation errors displayed to users for quick resolution
  • Better debugging support with detailed error output

Comprehensive Test Coverage (50+ new test cases):

  • Happy paths: Valid configs with required and optional fields
  • Missing required fields: name, symbol
  • Type mismatches: Strings, arrays, wrong types
  • Invalid patterns: Malformed Stellar addresses
  • Range violations: Out-of-bounds decimals
  • Enum validation: Invalid network selections
  • Malformed JSON: Syntax errors, empty files, arrays instead of objects
  • Schema violations: Field type mismatches
  • CLI integration tests for end-to-end validation

Example User Experience:
Before: Configuration validation failed.
After:

✓ Loaded config from .bc-forge.json
⚠ Configuration validation errors in .bc-forge.json:
  • Missing required field: "name"
  • /decimals: expected integer, got string
  • /admin: invalid format. Expected pattern: ^G[A-Z2-7]{55}$

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • CI
  • Chore

Checklist

  • I ran pre-commit run --all-files locally and it passed
  • All CI jobs pass on this branch
  • I added or updated tests for new behaviour
  • I updated relevant docs / comments
  • No secrets or credentials are included
  • No breaking changes to public APIs (or I've documented them)

Breaking changes?

No - This is a pure enhancement to error messages and validation. All existing valid configurations continue to work exactly as before. Only malformed configurations that would have failed anyway now provide better error guidance.

Related issues

Closes #709 - Ensure malformed configs are rejected cleanly

Files Changed:

  • config-parser.ts - Enhanced validation with detailed errors
  • config.ts - Improved error logging
  • config-parser.test.ts - Comprehensive unit tests
  • parseArgs.test.ts - CLI integration tests

…or reporting

Implement professional validation and error reporting for malformed .bc-forge.json configuration files. The CLI now rejects invalid configurations cleanly with specific, actionable error messages that guide users to fix their config issues.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Dekah101 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Testing] Test .bc-forge.json config validation

1 participant