Skip to content

Missing COMPARAM references cause conversion failure. (even in lenient mode for project specific odx files)Β #24

@arvindr19

Description

@arvindr19

Converter fails with "Couldn't find COMPARAM" error when COMPARAM-REF points to non-existent ID

Description

When ODX files contain COMPARAM-REF elements that reference non-existent COMPARAM IDs, the converter fails with an IllegalStateException. While lenient mode exists, there may be cases where references are broken or incomplete in real-world ODX files.

Error Message:

$java -jar converter/build/libs/converter-all.jar test-cases/issue2-missing-comparam.pdx
odx-converter - version: 0.1.0-SNAPSHOT

Processing issue2-missing-comparam.pdx
Error while processing issue2-missing-comparam.pdx: java.lang.IllegalStateException: Couldn't find COMPARAM cp-missing-999 @ SAMPLE_CPS
        at DatabaseWriter.offset(DatabaseWriter.kt:2113)
        at DatabaseWriter.offsetType(DatabaseWriter.kt:1600)
        at DatabaseWriter.offset(DatabaseWriter.kt:1612)
        at DatabaseWriter.<init>(DatabaseWriter.kt:226)
        at ChunkBuilder.createEcuDataChunk(ChunkBuilder.kt:120)
        at FileConverter.convert(Converter.kt:153)
        at Converter.run$lambda$4$lambda$3(Converter.kt:300)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Finished processing issue2-missing-comparam.pdx after 174.595983ms

Root Cause:
In DatabaseWriter.kt around line 2107-2113:

private fun COMPARAMREF.offset(): Int =
    cachedObjects.getOrPut(this) {
        val comParam = odx.comparams[this.idref]?.offset()
            ?: odx.complexComparams[this.idref]?.offset()

        if (comParam == null) {
            if (!options.lenient) {
                throw IllegalStateException("Couldn't find COMPARAM ${this.idref} @ ${this.docref}")
            }
            logger.warning("Couldn't find COMPARAM ${this.idref} @ ${this.docref}")
        }
        // ... continues but may have null comParam

Issue:

  1. The lenient mode logs a warning but continues with a potentially null comParam
  2. This may cause NullPointerException or incorrect data downstream
  3. Better handling needed for missing references

Reproduction:
See attached test case: issue2-missing-comparam.pdx


attached odx & pdx for repro.

issue2-missing-comparam.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions