load-plan-query-validator
v1.0.1
Published
Load Plan Query Validator is a command-line tool that validates load plan queries against a predefined schema. It ensures that the queries are correctly structured and adhere to the expected format, helping developers identify and fix issues before execut
Maintainers
Readme
🚀 Load Plan Query Validator
Load Plan Query Validator is a Node.js command-line tool that validates SOQL queries defined inside a Salesforce load plan file by executing them against a target org using the Salesforce CLI.
It helps you detect:
- ❌ Invalid fields
- ❌ Missing objects
- ❌ Relationship errors
- ❌ Syntax issues
- ❌ Schema mismatches
Before running any actual data migration or load process.
📦 Installation
npm install -g load-plan-query-validatorRunning
load-plan-query-validator --help⚙️ Requirements
- Node.js 18+
- Salesforce CLI installed 👉 https://developer.salesforce.com/tools/salesforcecli
- Authenticated Salesforce org (
sf org login)
🧠 How It Works
The tool:
- Reads
load-plan.json - Extracts each object’s
query - Executes:
sf data query -u <org> -q "<SOQL>" --jsonCaptures success or error
Prints a summary report
Returns:
0→ All queries valid1→ At least one query failed
🏃 Usage
load-plan-query-validator \
-o <salesforce-username-or-alias> \
-l <load-plan.json>Example
load-plan-query-validator -o ea11 -l load-plan.json📄 Example load-plan.json Entry
{
"object": "Product2",
"compositeKeys": ["StockKeepingUnit"],
"query": "SELECT StockKeepingUnit, Name, ProductCode FROM Product2",
"fieldMappings": {
"StockKeepingUnit": "StockKeepingUnit",
"Name": "Name",
"ProductCode": "ProductCode"
}
}📊 Example Output
🔍 Validating queries against org: devhub
→ Checking: AttributeCategory
✔ Query OK (12 records)
→ Checking: Product2
✖ Query Failed
No such column 'InvalidField__c' on entity 'Product2'.
====================================
📊 Validation Summary
====================================
✔ Successful Queries: 24
✖ Failed Queries: 1
❌ Error Details:
1. Object: Product2
Query: SELECT InvalidField__c FROM Product2
Error: No such column 'InvalidField__c' on entity 'Product2'.🔎 What This Tool Catches
- Missing fields
- Misspelled relationship paths
- Invalid lookup references
- Non-existent objects
- Permission-related query failures
- Schema drift between orgs
🎯 Why Use This?
Before running:
- Data migrations
- CPQ configuration loads
- Industry Cloud deployments
- Metadata-driven imports
- CI/CD validation
This tool ensures your queries are safe and valid.
🛠 CLI Options
| Option | Description |
| ------------------------ | -------------------------------- |
| -o, --org <username> | Salesforce org username or alias |
| -l, --load-plan <file> | Path to load-plan.json |
🧾 Exit Codes
| Code | Meaning |
| ---- | -------------------------- |
| 0 | All queries valid |
| 1 | One or more queries failed |
This makes it CI/CD friendly.
💡 Future Enhancements (Planned)
- Parallel execution
- Markdown error report export
- CSV export
- Duplicate object detection
- Dependency graph visualization
- CI GitHub Action template
- Schema comparison mode
📜 License
MIT License © Mohan Chinnappan
