Skip to content

Conversation

JayKid
Copy link
Contributor

@JayKid JayKid commented Sep 5, 2025

Description

Return status code instead of throwing the whole handler

The PR basically wraps the CRUD customerIntent endpoints in a try catch and returns appropriate status codes instead of allowing the hasAccess function throwing an error to crash the handler.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Return status code instead of throwing the whole handler
Copy link

github-actions bot commented Sep 5, 2025

This PR will trigger a patch release when merged.

@ravverma
Copy link
Contributor

ravverma commented Sep 8, 2025

@JayKid
Rather having try/catch everywhere , I would handle the error from AccessControlUtil at one place , where it is calling the hasAccess in method getSiteAndValidateLlmo and throw forbidden with message.
https://github.com/adobe/spacecat-api-service/pull/1226/files#diff-98f4e781fc94ce98289e072f10ebfb77c9028d87b18bfdf3d455fc232f8065c0R42

const { llmoConfig } = await getSiteAndValidateLlmo(context);
return ok(llmoConfig.customerIntent || []);
try {
const { llmoConfig } = await getSiteAndValidateLlmo(context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle it in getSiteAndValidateLlmo method itself rather everyplace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants