Skip to content

Commit cad4566

Browse files
committed
more canary logs
1 parent 8958d32 commit cad4566

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

canaries/integration_test/main_test.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,25 @@ void main() {
103103
final queryResponse = await Amplify.API.query(request: queryRequest).response;
104104
expect(queryResponse.hasErrors, isFalse);
105105
expect(queryResponse.data?.id, createdTodo.id);
106+
final queriedTodo = queryResponse.data!;
106107

107108
// === API: Delete Todo (cleanup) ===
108-
final deleteMutation = ModelMutations.delete(createdTodo);
109+
// Use the queried todo which reflects the actual DB state including the owner
110+
// field as set by AppSync (which uses the cognito:username from the JWT token)
111+
final deleteMutation = ModelMutations.delete(queriedTodo);
109112
final deleteResponse =
110113
await Amplify.API.mutate(request: deleteMutation).response;
114+
if (deleteResponse.hasErrors) {
115+
// Log only error types (safe enums like "Unauthorized", "ConflictUndetected")
116+
// Do NOT log error messages or field values which may contain sensitive data
117+
final errorTypes = deleteResponse.errors
118+
?.map((e) => e.errorType ?? 'Unknown')
119+
.join(', ');
120+
AWSLogger().error('Delete mutation failed with ${deleteResponse.errors?.length ?? 0} error(s). Types: $errorTypes');
121+
// Log only whether values match, not the actual values
122+
final ownerMatch = queriedTodo.owner == createdTodo.owner;
123+
AWSLogger().error('Owner field matches between queried and created todo: $ownerMatch');
124+
}
111125
expect(deleteResponse.hasErrors, isFalse);
112126

113127
// === DATASTORE: Save and observe ===

0 commit comments

Comments
 (0)