Skip to content

Commit 83796eb

Browse files
authored
Merge pull request #185 from cipherstash/error-message-for-mappingerrorstatementcouldnotbemapped
Add details of StatementCouldNotBeMapped in errors.md
2 parents 048169b + a42d247 commit 83796eb

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

docs/errors.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Invalid parameter](#mapping-invalid-parameter)
1313
- [Invalid SQL statement](#mapping-invalid-sql-statement)
1414
- [Unsupported parameter type](#mapping-unsupported-parameter-type)
15+
- [Statement could not be type checked](#mapping-statement-could-not-be-type-checked)
1516
- [Internal Error](#mapping-internal-error)
1617

1718
- Encrypt Errors:
@@ -167,13 +168,59 @@ Check the supported types for encrypted columns.
167168

168169

169170

171+
<!-- ---------------------------------------------------------------------------------------------------- -->
172+
173+
174+
## Statement could not be type checked <a id='mapping-statement-could-not-be-type-checked'></a>
175+
176+
An error occurred when attempting to type check the SQL statement.
177+
178+
### Error message
179+
180+
```
181+
Statement could not be type checked: '{type-check-erro-message}'
182+
```
183+
184+
### Notes
185+
186+
CipherStash Proxy checks SQL statements against the database schema to transparently encrypt and decrypt data.
187+
188+
The behaviour of Proxy depends on the `mapping_errors_enabled` configuration.
189+
190+
When `mapping_errors_enabled` is `false` (the default), then type check errors are logged, and the statement is passed through to the database.
191+
192+
When `mapping_errors_enabled` is `true`, then type check errors are raised, and statement execution halts.
193+
194+
In our experience, most production systems have a relatively small number of columns that require protection.
195+
As SQL is large and complex, instead of blocking statements with type check errors that are false negatives, the default behaviour of Proxy is to allow the statement.
196+
197+
However, this does mean it is possible that a statement that references encrypted columns cannot be type-checked, and it will be passed through to the database.
198+
When a statement is passed through to the database, the database's column constraints (provided by EQL) will catch the statement, and return a PostgreSQL error.
199+
200+
Example constraint error:
201+
```sql
202+
ERROR: Encrypted column missing version (v) field: 34234
203+
CONTEXT: PL/pgSQL function _cs_encrypted_check_v(jsonb) line 6 at RAISE
204+
SQL function "cs_check_encrypted_v1" statement 1
205+
```
206+
207+
### How to Fix
208+
209+
In most cases, this error will occur if the statement contains invalid or unsupported syntax.
210+
211+
Check if you are running the latest version of CipherStash Proxy, and update to the latest version if not.
212+
213+
If the error persists, please contact CipherStash [support](https://cipherstash.com/support).
214+
215+
216+
170217
<!-- ---------------------------------------------------------------------------------------------------- -->
171218

172219

173220
## Internal Mapper error <a id='mapping-internal-error'></a>
174221

175-
An internal error occurred when attempting to rewrite the SQL statement.
176-
This could be due to an internal invariant failure or because of a specific fragment of unsupported SQL syntax.
222+
An internal error occurred when attempting to type check or transform a SQL statement.
223+
This could be due to an internal invariant failure, or because of a specific fragment of unsupported SQL syntax.
177224

178225
### Error message
179226

@@ -183,7 +230,7 @@ Statement encountered an internal error. This may be a bug in the statement mapp
183230

184231
### How to Fix
185232

186-
If you are running an older version of CipherStash Proxy, please update to the latest version.
233+
Check if you are running the latest version of CipherStash Proxy, and update to the latest version if not.
187234

188235
If the error persists, please contact CipherStash [support](https://cipherstash.com/support).
189236

packages/cipherstash-proxy/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub enum MappingError {
8080
#[error("Encryption of PostgreSQL {name} (OID {oid}) types is not currently supported. For help visit {}#mapping-unsupported-parameter-type", ERROR_DOC_BASE_URL)]
8181
UnsupportedParameterType { name: String, oid: u32 },
8282

83-
#[error("Statement could not be type checked: {}. For help visit {}#mapping-statement-could-not-be-mapped", _0, ERROR_DOC_BASE_URL)]
84-
StatementCouldNotBeMapped(String),
83+
#[error("Statement could not be type checked: {}. For help visit {}#mapping-statement-could-not-be-type-checked", _0, ERROR_DOC_BASE_URL)]
84+
StatementCouldNotBeTypeChecked(String),
8585

8686
#[error("Statement could not be transformed: {0}")]
8787
StatementCouldNotBeTransformed(String),

packages/cipherstash-proxy/src/postgresql/frontend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ where
755755
error = err.to_string(),
756756
);
757757
counter!(STATEMENTS_UNMAPPABLE_TOTAL).increment(1);
758-
Err(MappingError::StatementCouldNotBeMapped(err.to_string()).into())
758+
Err(MappingError::StatementCouldNotBeTypeChecked(err.to_string()).into())
759759
}
760760
}
761761
}

packages/eql-mapper/src/eql_mapper.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ pub enum EqlMapperError {
127127
#[error("Internal error: {}", _0)]
128128
InternalError(String),
129129

130-
#[error("Unsupported value variant: {}", _0)]
131-
UnsupportedValueVariant(String),
132-
133130
/// A lexical scope error
134131
#[error(transparent)]
135132
Scope(#[from] ScopeError),

0 commit comments

Comments
 (0)