@@ -149,7 +149,10 @@ export class ReportsService {
149149
150150 const command = new GetItemCommand ( {
151151 TableName : this . tableName ,
152- Key : marshall ( { id } ) ,
152+ Key : marshall ( {
153+ userId, // Partition key
154+ id, // Sort key
155+ } ) ,
153156 } ) ;
154157
155158 try {
@@ -161,14 +164,9 @@ export class ReportsService {
161164
162165 const report = unmarshall ( response . Item ) as Report ;
163166
164- // Verify the report belongs to the user
165- if ( report . userId !== userId ) {
166- throw new ForbiddenException ( 'You do not have permission to access this report' ) ;
167- }
168-
169167 return report ;
170168 } catch ( error : unknown ) {
171- if ( error instanceof NotFoundException ) {
169+ if ( error instanceof NotFoundException || error instanceof ForbiddenException ) {
172170 throw error ;
173171 }
174172
@@ -180,6 +178,14 @@ export class ReportsService {
180178 throw new InternalServerErrorException (
181179 `Table "${ this . tableName } " not found. Please check your database configuration.` ,
182180 ) ;
181+ } else if ( error . name === 'UnrecognizedClientException' ) {
182+ throw new InternalServerErrorException (
183+ 'Invalid AWS credentials. Please check your AWS configuration.' ,
184+ ) ;
185+ } else if ( error . name === 'ValidationException' ) {
186+ throw new InternalServerErrorException (
187+ 'The provided key structure does not match the table schema. Please check your DynamoDB table configuration.' ,
188+ ) ;
183189 }
184190 }
185191
0 commit comments