apache / apache/hop

[Bug]: Combination Lookup SQL button throws NPE (parent pipeline is null)

Open Beginner friendly
#8,283 0 comments 0 reactions 0 assignees View on GitHub
awaiting triage Hop Gui P2 Transforms
Dominant language
Java
Stars
1.5k
Forks
476
Avg merge
18h 32m
Merged PRs (30d)
216

Description

### Apache Hop version?

2.19.0 (also present on current `main`)

### Java version?

21

### Operating system

Linux

### What happened?

Clicking **SQL** on Combination Lookup throws:

```
java.lang.NullPointerException: Cannot invoke "org.apache.hop.pipeline.PipelineMeta.findDatabase(String, org.apache.hop.core.variables.IVariables)" because the return value of "org.apache.hop.pipeline.transform.TransformMeta.getParentPipelineMeta()" is null
at org.apache.hop.pipeline.transforms.combinationlookup.CombinationLookupMeta.getSqlStatements(CombinationLookupMeta.java:425)
at org.apache.hop.pipeline.transforms.combinationlookup.CombinationLookupDialog.create(CombinationLookupDialog.java:900)
```

The dialog builds a **temporary** meta and wraps it in a new `TransformMeta`. That wrapper never gets a parent pipeline:

```java
CombinationLookupMeta info = new CombinationLookupMeta();
getInfo(info);
TransformMeta transformMeta = new TransformMeta(..., name, info);
info.getSqlStatements(variables, pipelineMeta, transformMeta, prev, metadataProvider);
```

`TransformMeta.setTransform()` does call `setParentTransformMeta(this)`, so `getParentTransformMeta()` is non-null. `getParentPipelineMeta()` stays null.

`getSqlStatements` (and `analyseImpact`) then ignore the `pipelineMeta` argument and go through the parent:

```java
DatabaseMeta databaseMeta =
getParentTransformMeta().getParentPipelineMeta().findDatabase(connectionName, variables);
```

https://github.com/apache/hop/blob/main/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java#L424-L425

https://github.com/apache/hop/blob/main/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java#L676-L677

Dimension Lookup already does the right thing in `getSqlStatements`:

```java
DatabaseMeta databaseMeta = pipelineMeta.findDatabase(connection, variables);
```

https://github.com/apache/hop/blob/main/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupMeta.java#L891

### Steps to reproduce

1. Open a pipeline with a Combination Lookup that has a connection, table, and incoming key fields.
2. Open the Combination Lookup dialog.
3. Click **SQL**.

**Expected:** SQL editor (or “no SQL needed”).
**Actual:** NPE as above.

### Suggested fix

Use the `pipelineMeta` passed into `getSqlStatements` / `analyseImpact`:

```java
DatabaseMeta databaseMeta = pipelineMeta.findDatabase(connectionName, variables);
```

### Issue Priority

Priority: 2

### Issue Component

Component: Transforms
Component: Hop Gui

Contributor guide

Open the contributing guide

Research direction

Start in plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java, reading getSqlStatements and analyseImpact, then follow the call from CombinationLookupDialog.create. Reproduce the SQL action with a configured Combination Lookup and verify that the dialog opens without an NPE and impact analysis also handles the temporary transform context correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data-engineering
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.