Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.cdap.cdap.proto.ProgramType;
import io.cdap.cdap.proto.codec.NamespacedEntityIdCodec;
import io.cdap.cdap.proto.id.DatasetId;
import io.cdap.cdap.proto.id.NamespaceId;
import io.cdap.cdap.proto.id.NamespacedEntityId;
import io.cdap.cdap.proto.id.ProgramReference;
import io.cdap.cdap.proto.metadata.lineage.CollapseType;
Expand Down Expand Up @@ -142,6 +143,8 @@ public void getEndpointSummary(HttpRequest request, HttpResponder responder,
@PathParam("program-type") String programType,
@PathParam("program-name") String programName,
@PathParam("run-id") String runId) throws Exception {
accessEnforcer.enforce(new NamespaceId(namespaceId), authenticationContext.getPrincipal(),
StandardPermission.GET);
Comment on lines +146 to +147

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

While adding the authorization check here is correct, there is an existing control flow bug in this method. In the catch block (lines 154–156), when an exception is caught, responder.sendJson is called to send a BAD_REQUEST response, but the method does not return.

Consequently, the execution continues to line 157:

EndpointsSummary endpointSummary = fieldLineageAdmin.getEndpoints(namespaceId, programReference, RunIds.fromString(runId));

This will:

  1. Re-evaluate RunIds.fromString(runId), which will throw the same exception again outside the try-catch block, causing a 500 Internal Server Error or propagating an unhandled exception after a response has already been committed.
  2. If ProgramType.valueOfCategoryName failed, programReference will be null, which is then passed to getEndpoints and may cause a NullPointerException.

To fix this, please add a return; statement inside the catch block:

    } catch (Exception e) {
      responder.sendJson(HttpResponseStatus.BAD_REQUEST, e.getMessage());
      return;
    }

ProgramReference programReference = null;
try {
RunIds.fromString(runId);
Expand Down