validate_rule
Validate a product rule (Attribute Rule) WITHOUT saving it. ALWAYS call this before create_rule / update_rule and fix every error first. Pass the full rule document as rule — {name, description, category, icon, rules:[{sortId, enabled, type, conditions, operationGroups:[{mode, parentMode, attributes, operations: [{name, arguments:{key:value}}]}]}]} (see discover_rule_operations for the operation/condition/argument vocabulary). Returns {valid, errors:[{path, code, message}], warnings:[{path, code, message}], dryRun}. Errors are blocking — the rule will be rejected on save; warnings are advisory. If you also pass a sample_product (a flat {attributeCode:value} record, e.g. from preview_products) and the rule is structurally valid, the server dry-runs it and returns dryRun:{matchedRuleSortId, computedValue, usedAttributes} so you can confirm the output before saving. This tool NEVER writes. project_id is OPTIONAL (inferred for a single-project customer; project_id_required otherwise — then call list_projects). When you do NOT pass sample_product, the server auto-samples a real product to compute dryRun, so the computedValue is real data returned only after you set acknowledge_sensitive:true: the first such call (flag absent/false) returns {sensitiveGate:{confirmationRequired:true, itemCount, fields, kind}} with the computedValue EMPTY — present that gate to the USER, get their approval, then re-call with acknowledge_sensitive:true. (If you passed your own sample_product you already hold that data, so no gate applies and the computedValue is returned directly.) DRY-RUN LIMITATION: AI-group operations — notably map_attribute_value (value/options mapping) — are NOT executed by the dry-run. It returns valid:true with computedValue = the input UNCHANGED (passthrough) even when the mapping is correct; this is expected, not a bug, so do NOT treat the unchanged value as a failure. Verify a value/options mapping only AFTER a real build/export: feed → export_feed then verify_feed_attributes; marketplace/ad → repair_marketplace / run_marketplace_operation (or the ad equivalents) then get_*_report.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes | ||
| project_id | No | ||
| sample_product | No | A flat {attributeCode:value} record (e.g. from preview_products) to dry-run the rule against; when omitted the server auto-samples a real product. | |
| acknowledge_sensitive | No | Set true only AFTER the user approves seeing real data. Only relevant when the server auto-samples (no sample_product given): absent/false returns a sensitiveGate with computedValue empty; true returns it. |