Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lambda-tiler): Remove the job id to use ulid and update HTTP status code. #2188

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/lambda-tiler/src/__test__/tile.import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ o.spec('Import', () => {

// When ...Then ...
const res = await Import(req);
o(res.body).equals('{"status":500,"message":"Invalid s3 path"}');
o(res.body).equals('{"status":400,"message":"Invalid s3 path: s3::testbucket/"}');
});

o('should return Unable to access bucket', async () => {
Expand All @@ -100,7 +100,7 @@ o.spec('Import', () => {

// When ...Then ...
const res = await Import(req);
o(res.body).equals('{"status":500,"message":"Unable to Access the bucket"}');
o(res.body).equals('{"status":403,"message":"Unable to Access the s3 bucket"}');
});

o('should return Imagery not found', async () => {
Expand Down
7 changes: 3 additions & 4 deletions packages/lambda-tiler/src/routes/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export async function Import(req: LambdaHttpRequest): Promise<LambdaHttpResponse
}

// Find the imagery from s3
if (path == null || !path.startsWith('s3://')) return new LambdaHttpResponse(500, 'Invalid s3 path');
if (path == null || !path.startsWith('s3://')) return new LambdaHttpResponse(400, `Invalid s3 path: ${path}`);
const role = await RoleRegister.findRole(path);
if (role == null) return new LambdaHttpResponse(500, 'Unable to Access the bucket');
if (role == null) return new LambdaHttpResponse(403, 'Unable to Access the s3 bucket');
const files = await findImagery(path);
if (files.length === 0) return new LambdaHttpResponse(404, 'Imagery Not Found');

Expand All @@ -40,7 +40,6 @@ export async function Import(req: LambdaHttpRequest): Promise<LambdaHttpResponse
let jobConfig = await Config.ProcessingJob.get(jobId);
if (jobConfig == null) {
// Add id back to JobCreationContext
ctx.override!.id = id;
ctx.outputLocation.path = fsa.join(ctx.outputLocation.path, id);

// Insert Processing job config
Expand All @@ -51,7 +50,7 @@ export async function Import(req: LambdaHttpRequest): Promise<LambdaHttpResponse
} as ConfigProcessingJob;

if (Config.ProcessingJob.isWriteable()) await Config.ProcessingJob.put(jobConfig);
else return new LambdaHttpResponse(500, 'Unable to insert the Processing Job config');
else return new LambdaHttpResponse(403, 'Unable to insert the Processing Job config');

// Start processing job
await CogJobFactory.create(ctx);
Expand Down