{"record":{"id":"c0e48729a48e5b7c","repo":"OtterMind/Chat2DB","slug":"invalid-sql-server-view-attribute-viewattribute","errorCode":null,"errorMessage":"Invalid SQL Server view attribute: {viewAttribute}","messagePattern":"Invalid SQL Server view attribute: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-sqlserver/src/main/java/ai/chat2db/plugin/sqlserver/builder/SqlServerSqlBuilder.java","lineNumber":475,"sourceCode":"                    .append(SQLConstants.SINGLE_QUOTE).append(SqlServerIdentifierProcessor.INSTANCE.escapeString(viewName)).append(SQLConstants.SINGLE_QUOTE);\n\n        }\n\n        return createViewSqlBuilder.toString();\n    }\n\n    @Override\n    public String buildExplain(String sql) {\n        return SQL_SET_SHOWPLAN_XML_ON_SEMICOLON_GO + sql + SQL_GO_SET_SHOWPLAN_XML_OFF_SEMICOLON;\n    }\n\n    private static void validateViewAttribute(String viewAttribute) {\n        for (SqlServerViewAttributeOptionEnum option : SqlServerViewAttributeOptionEnum.values()) {\n            if (option.name().equalsIgnoreCase(viewAttribute)) {\n                return;\n            }\n        }\n        throw new IllegalArgumentException(\"Invalid SQL Server view attribute: \" + viewAttribute);\n    }\n}\n","sourceCodeStart":457,"sourceCodeEnd":478,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-sqlserver/src/main/java/ai/chat2db/plugin/sqlserver/builder/SqlServerSqlBuilder.java#L457-L478","documentation":"Thrown by SqlServerSqlBuilder.validateViewAttribute when the supplied view attribute string matches none of the SqlServerViewAttributeOptionEnum names (compared case-insensitively). The method exists to whitelist only known view options before they are embedded into generated DDL.","triggerScenarios":"Calling the view-DDL builder with a viewAttribute that is not one of the recognized SqlServerViewAttributeOptionEnum values - e.g. a free-text option, a typo, or a value from another dialect.","commonSituations":"UI passing a label instead of the enum name; cross-dialect metadata carrying an unsupported option; version mismatch where the enum lacks a newly added SQL Server view attribute.","solutions":["Set viewAttribute to a value that matches a SqlServerViewAttributeOptionEnum name exactly (case-insensitive).","If no view attribute applies, pass null/blank rather than an arbitrary string if the caller path supports omission.","Extend SqlServerViewAttributeOptionEnum if a legitimate SQL Server option is missing."],"exampleFix":"// before\nview.setAttribute(\"SCHEMABINDINGS\"); // typo\n// -> Invalid SQL Server view attribute\n\n// after\nview.setAttribute(\"SCHEMABINDING\"); // matches enum name","handlingStrategy":"type-guard","validationCode":"boolean ok = Arrays.stream(SqlServerViewAttributeOptionEnum.values())\n    .anyMatch(o -> o.name().equalsIgnoreCase(viewAttribute));\nif (StringUtils.isNotBlank(viewAttribute) && !ok) {\n    throw new IllegalArgumentException(\"Unsupported view attribute: \" + viewAttribute);\n}","typeGuard":"static boolean isSupportedSqlServerViewAttribute(String v) {\n    return v != null && Arrays.stream(SqlServerViewAttributeOptionEnum.values())\n        .anyMatch(o -> o.name().equalsIgnoreCase(v));\n}","tryCatchPattern":null,"preventionTips":["Pass only enum names for view attributes.","Extend the enum if a legitimate SQL Server option is missing.","Validate at the UI/API boundary."],"tags":["sqlserver","ddl","view","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}