{"record":{"id":"061095c91e85c0f5","repo":"dianping/cat","slug":"expected-but-found","errorCode":null,"errorMessage":"Expected ({}) but found '{}'.","messagePattern":"Expected \\((.+?)\\) but found '(.+?)'\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-css.js","lineNumber":5169,"sourceCode":"        var result      = false,\n            value       = expression.value,\n            count       = 0,\n            part;\n\n        while (expression.hasNext() && count < max) {\n            result = ValidationTypes.isAny(expression, types);\n            if (!result) {\n                break;\n            }\n            count++;\n        }\n\n        if (!result) {\n            if (expression.hasNext() && !expression.isFirst()) {\n                part = expression.peek();\n                throw new ValidationError(\"Expected end of value but found '\" + part + \"'.\", part.line, part.col);\n            } else {\n                 throw new ValidationError(\"Expected (\" + types + \") but found '\" + value + \"'.\", value.line, value.col);\n            }\n        } else if (expression.hasNext()) {\n            part = expression.next();\n            throw new ValidationError(\"Expected end of value but found '\" + part + \"'.\", part.line, part.col);\n        }\n\n    },\n\n    multiProperty: function (types, expression, comma, max) {\n\n        var result      = false,\n            value       = expression.value,\n            count       = 0,\n            sep         = false,\n            part;\n\n        while(expression.hasNext() && !result && count < max) {\n            if (ValidationTypes.isAny(expression, types)) {","sourceCodeStart":5151,"sourceCodeEnd":5187,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-css.js#L5151-L5187","documentation":"The total-miss branch of `Validation.singleProperty`: no token of the value matched the expected type expression at all (`result` false and the expression is at its first token), so it throws `ValidationError(\"Expected (\" + types + \") but found 'value'\")` anchored at the value's position. The message interpolates the internal type expression (e.g. `<length> | <percentage> | inherit`), which is exactly what the property accepts.","triggerScenarios":"`display: foo`, `z-index: high`, `width: lots`, `overflow: sometimes` — the first value token matches none of the allowed types. Any singleProperty-validated property (`spec` string without `||`, or `multi` with `isFirst()` true) given a completely wrong value.","commonSituations":"Typos and keyword guesses; values copied from a different property; unquoted templating that substitutes an identifier the grammar cannot match; legacy keywords removed from the table.","solutions":["Read the 'Expected (...)' clause in the message — it lists the accepted types/keywords verbatim; pick a value matching it.","If the value came from a variable/template, print the rendered CSS and fix the substitution.","If the keyword is valid modern CSS, upgrade the validator table (see unknown-property solutions) since old tables lack new keywords."],"exampleFix":"/* before */\n.layer { z-index: high; } /* Expected (<integer> | auto) but found 'high' */\n\n/* after */\n.layer { z-index: 10; }","handlingStrategy":"try-catch","validationCode":"// mirror the type expression from the error message to pre-check a value you generate\nfunction matchesTypeExpr(types, token) {\n  // e.g. types='<integer> | auto'\n  if (/integer|number/.test(types) && /^-?\\d+$/.test(token)) return true;\n  if (/length/.test(types) && /^-?\\d+(px|em|rem|%)$/.test(token)) return true;\n  return types.split('|').map(function (t) { return t.trim(); }).indexOf(token) !== -1;\n}","typeGuard":null,"tryCatchPattern":"try {\n  Validation.validate(property, value);\n} catch (ex) {\n  if (/^Expected \\(/.test(ex.message)) { addLint(ex.line, ex.col, ex.message); return; } // message contains the accepted grammar\n  throw ex;\n}","preventionTips":["Read the 'Expected (...)' grammar in the message — it enumerates exactly what is accepted.","For generated CSS, unit-test emitters against the validator's grammar strings.","Log the rendered value when templating produces values, since substitutions often cause total mismatches."],"tags":["css","validation","property-value","syntax-error"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}