Skip to content

Conversation

@xschildw
Copy link
Contributor

@xschildw xschildw commented Jul 10, 2025

Depends on Sage-Bionetworks/synapse-markdown-it-lambda#3 to be deployed before building (need actual function name to call).

@dpulls
Copy link

dpulls bot commented Jul 11, 2025

🎉 All dependencies have been resolved !

@xschildw xschildw marked this pull request as ready for review October 23, 2025 03:30
@xschildw xschildw requested a review from marcomarasca October 23, 2025 03:30
ReflectionTestUtils.setField(dao, "markdownClient", mockMarkdownClient);
dao.setSynapseBaseUrl("https://www.synapse.org");
dao.setStack("dev");
ReflectionTestUtils.setField(dao, "lambdaClient", mockLambdaClient);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the utility, use junit 5 @Injectmocks instead

InvokeResult result = lambdaClient.invoke(invokeRequest);

if (result.getFunctionError() != null) {
throw new MarkdownClientException(500, "Lambda execution failed: " + result.getFunctionError());
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably log more details from response (the docs says more details are in the result.getPayload(), also the result object has a getStatusCode() function that we can use instead of 500.

@marcomarasca
Copy link
Contributor

I also want to point out that I'm not sure why we need any of this in the first place. As far as I can tell from the code we only use it to convert some markdown into an html email, can't we just use an html template for the email as we do in other places? I do not see this used in the webclient and the current lambda URL is not publicly accessible (but I might be missing something) either so maybe we do not need the lambda at all?

import software.amazon.awssdk.services.lambda.LambdaClient;

@Configuration
@ImportResource("classpath:stack-configuration.spb.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

Very cool, thanks!

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:test-context.xml"})
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {MarkdownConfig.class})
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

<!-- Load the single cloudwatch consumer -->
<import resource="classpath:cloudwatch-spb.xml" />
<!-- Markdown service -->
<import resource="classpath:markdown-dao.spb.xml" />
Copy link
Contributor

Choose a reason for hiding this comment

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

How is the MarkdownConfig imported where it is used? Maybe through the ManagerConfiguration? Unfortunately, the code structure is very convoluted and while this is only used by the workers application it is currently imported by the manager (which is also included in the repo API application).

@Bean
@Scope("singleton")
public MarkdownDao markdownDao() {
MarkdownDaoImpl markdownDao = new MarkdownDaoImpl(lambdaClient(), stackConfiguration.getSynapseBaseUrl(), stackConfiguration.getStack());
Copy link
Contributor

Choose a reason for hiding this comment

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

The StackConfiguration instance can be a parameter of this method rather than an object property, the LambdaClient does not need to be an exported bean actually, if it needs to be "shared" I would rather have it exposed as a bean somewhere else. In other words, I think it's best if the MarkdownConfig does not add to the context beans that are not related to this module.

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.

2 participants