Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Undefined JSONPath expressions produce nil silently — hard to debug #12

Description

@lukacsi

Problem

When a JSONPath expression in a pipeline resolves to nothing (undefined field, typo), GetJSONPathRaw returns (nil, nil) by design. This is needed for @definedOr to work. But in @project context, nil values flow into the output object silently:

  • Critical fields (metadata.name/namespace): K8s rejects the object with a confusing error like "metadata/namespace must be a string (current value nil)" — no indication which expression failed
  • Non-critical fields (labels, config values, resources): silently null in the output, no error anywhere

Example

# Typo: $.MatrixRTCStack.metadata.namespace in a single-source pipeline
# (should be $.metadata.namespace — single-source doesn't use Kind prefix)
metadata:
  namespace: "$.MatrixRTCStack.metadata.namespace"

Error at runtime: invalid object: metadata/namespace must be a string (current value nil)

The actual cause (wrong JSONPath convention) is not visible in any log or event.

Root Cause

pkg/expression/jsonpath.go:108-111 — error return deliberately commented out, replaced with return nil, nil. This is correct for @definedOr (line 309 checks v == nil).

Suggestion

Add a DEBUG-level log when a JSONPath resolves to nil outside of @definedOr context, e.g.:

DEBUG  expression  JSONPath resolved to nil  {"expression": "$.MatrixRTCStack.metadata.namespace", "context": "@project"}

This preserves backward compatibility and @definedOr behavior while making typos visible in logs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions