{"record":{"id":"215e82a29befdddf","repo":"apache/shardingsphere","slug":"can-not-find-logic-encrypt-column-by-s","errorCode":null,"errorMessage":"Can not find logic encrypt column by '%s'.","messagePattern":"Can not find logic encrypt column by '(.+?)'\\.","errorType":"exception","errorClass":"EncryptLogicColumnNotFoundException","httpStatus":null,"severity":"error","filePath":"features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/table/EncryptTable.java","lineNumber":145,"sourceCode":"     */\n    public boolean isCipherColumn(final String columnName) {\n        return columns.values().stream().anyMatch(each -> each.getCipher().getName().equalsIgnoreCase(columnName));\n    }\n    \n    /**\n     * Get logic column by cipher column.\n     *\n     * @param cipherColumnName cipher column name\n     * @return logic column name\n     * @throws EncryptLogicColumnNotFoundException encrypt logic column not found exception\n     */\n    public String getLogicColumnByCipherColumn(final String cipherColumnName) {\n        for (Entry<String, EncryptColumn> entry : columns.entrySet()) {\n            if (entry.getValue().getCipher().getName().equalsIgnoreCase(cipherColumnName)) {\n                return entry.getValue().getName();\n            }\n        }\n        throw new EncryptLogicColumnNotFoundException(cipherColumnName);\n    }\n    \n    /**\n     * Get logic column by assisted query column.\n     *\n     * @param assistQueryColumnName assisted query column name\n     * @return logic column name\n     * @throws EncryptLogicColumnNotFoundException encrypt logic column not found exception\n     */\n    public String getLogicColumnByAssistedQueryColumn(final String assistQueryColumnName) {\n        for (Entry<String, EncryptColumn> entry : columns.entrySet()) {\n            if (entry.getValue().getAssistedQuery().isPresent() && entry.getValue().getAssistedQuery().get().getName().equalsIgnoreCase(assistQueryColumnName)) {\n                return entry.getValue().getName();\n            }\n        }\n        throw new EncryptLogicColumnNotFoundException(assistQueryColumnName);\n    }\n    ","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/table/EncryptTable.java#L127-L163","documentation":"Thrown by EncryptTable.getLogicColumnByCipherColumn when no logic encrypt column in the encrypt rule has a cipher column whose name equals (case-insensitively) the given column name. ShardingSphere uses this reverse lookup during SQL rewriting/decryption to map a cipher column appearing in a result set or SQL back to its logic column; if the encrypt rule never registered that cipher column, the mapping fails.","triggerScenarios":"Executing a SELECT/INSERT against an encrypt table where a column the engine classified as a cipher column (e.g. from the metadata or SQL projection) is not present as a 'cipher/name' entry in the encrypt rule's columns configuration for that table.","commonSituations":"Encrypt rule YAML defines columns with a different cipher-column name than what the SQL/metadata uses; a column was added to the table but not to the encrypt rule; rule was edited after metadata loaded; migrating config between environments where the cipher column suffix (e.g. _cipher vs _encrypted) differs.","solutions":["Compare the failing column name from the message with the 'columns:<logic>:cipher:name' entry in the ENCRYPT rule for that table and make them identical","Add the missing column (logic + cipher + assisted query if used) to the encrypt rule's columns section","Reload/refresh database metadata after changing the rule (restart proxy or ALTER ... REFRESH TABLE METADATA) so stale metadata does not reference an old cipher name","Check other environments' config for a renamed cipher column (e.g. pwd_cipher vs pwd_enc) and align them"],"exampleFix":"# before (rule)\nrules:\n- !ENCRYPT\n  tables:\n    t_user:\n      columns:\n        password:\n          cipher:\n            name: password_enc\n# SQL references password_cipher -> Can not find logic encrypt column by 'password_cipher'\n# after\nrules:\n- !ENCRYPT\n  tables:\n    t_user:\n      columns:\n        password:\n          cipher:\n            name: password_cipher","handlingStrategy":"validation","validationCode":"// Before enabling the encrypt rule, verify every cipher column referenced by the schema/SQL exists in the rule\nMap<String, String> cipherToLogic = new HashMap<>();\nencryptTableConfig.getColumns().forEach((logic, col) -> cipherToLogic.put(col.getCipher().getName().toLowerCase(), logic));\nif (!cipherToLogic.containsKey(columnName.toLowerCase())) throw new IllegalArgumentException(\"Column \" + columnName + \" is not a configured cipher column\");","typeGuard":null,"tryCatchPattern":"catch (EncryptLogicColumnNotFoundException ex) { log.warn(\"Cipher column {} not in encrypt rule; check columns config\", ex.getMessage()); throw ex; }","preventionTips":["Keep encrypt rule column config in sync with physical schema changes via migration tooling","Add a startup check that schema column names match the rule's cipher/assisted names","Avoid ad-hoc cipher column renames; change rule and schema together"],"tags":["encrypt","config","column-mapping","sql-rewriting"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}