weiqingy commented on code in PR #709:
URL: https://github.com/apache/flink-agents/pull/709#discussion_r3315347856
##########
plan/src/main/java/org/apache/flink/agents/plan/AgentPlan.java:
##########
@@ -228,20 +228,30 @@ private void extractActionsFromAgent(Agent agent) throws
Exception {
// Scan the agent class for methods annotated with @Action
Class<?> agentClass = agent.getClass();
for (Method method : agentClass.getDeclaredMethods()) {
- if
(method.isAnnotationPresent(org.apache.flink.agents.api.annotation.Action.class))
{
- org.apache.flink.agents.api.annotation.Action actionAnnotation
=
-
method.getAnnotation(org.apache.flink.agents.api.annotation.Action.class);
-
- String[] listenEventTypeStrings =
-
Objects.requireNonNull(actionAnnotation).listenEventTypes();
-
- org.apache.flink.agents.plan.JavaFunction javaFunction =
+ if
(!method.isAnnotationPresent(org.apache.flink.agents.api.annotation.Action.class))
{
+ continue;
+ }
+ org.apache.flink.agents.api.annotation.Action actionAnnotation =
+ Objects.requireNonNull(
+ method.getAnnotation(
+
org.apache.flink.agents.api.annotation.Action.class));
+ String[] listenEventTypeStrings =
actionAnnotation.listenEventTypes();
+ org.apache.flink.agents.api.annotation.PythonFunction target =
+ actionAnnotation.target();
+
+ org.apache.flink.agents.plan.Function execFunction;
+ if (target.module().isEmpty()) {
Review Comment:
The `module().isEmpty()` branch picks Java vs Python, but `qualname()` is
read unconditionally on the Python path without a non-empty check.
`@Action(target = @PythonFunction(module = "pkg"))` (no qualname) would build a
`PythonFunction("pkg", "")` and fail much later inside the interpreter with an
obscure error.
Would it make sense to validate here — e.g. both empty → Java; exactly one
set → reject with a message naming the action; both set → Python? Catching it
at extraction time would surface the typo at the layer where the user can
actually correct it. (Same question on the Python side — does
`@action(target=...)` reject a `JavaFunction` with an empty `method_name` or
`parameter_types`?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]