Skip to content

fix: drop empty path and unrenderable value from function call errors - #140

Open
somaz94 wants to merge 1 commit into
kubevela:mainfrom
somaz94:fix/cuex-function-call-error-message
Open

somaz94 wants to merge 1 commit into
kubevela:mainfrom
somaz94:fix/cuex-function-call-error-message

Conversation

@somaz94

@somaz94 somaz94 commented Sep 8, 2026

Copy link
Copy Markdown

What this changes

FunctionCallError.Error() builds its message from three parts unconditionally, so when a part is
missing the message shows the gap instead of omitting it:

  • Path is empty for a root value, which renders as function call error for : ... with nothing
    before the colon.
  • NewFunctionCallError puts the formatting failure into the Value field when util.ToString
    fails, so the message ends with (value: cue/format: unsupported node type <nil>). That reads as
    though the user's value caused a CUE problem, and sends people looking for a CUE error in their own
    input that is not there.

Both clauses are now emitted only when they carry something. A message that has both parts is
unchanged.

Case Before After
path and value present function call error for a.b: err (value: "c") unchanged
empty path function call error for : err (value: "c") function call error: err (value: "c")
value could not be rendered ... (value: cue/format: unsupported node type <nil>) clause omitted

Reported in kubevela/kubevela#7365, where it surfaces on every shared-resource conflict:

shared-cm: function call error for : Dispatch: pre-dispatch dryrun failed: Found 1 errors.
[(cannot apply ApplyOption: existing object ConfigMap default/contested-cm is managed by other
application default/owner-a)] (value: cue/format: unsupported node type <nil>)

That issue also needs a go.mod bump in kubevela/kubevela before the fix reaches users, so I have
not used a closing keyword here.

Note on Value

When the value cannot be rendered, the exported FunctionCallError.Value field is now empty rather
than holding the formatting error's text. FunctionCallError is only constructed and read inside
cue/cuex, and the existing case in compiler_test.go passes a non-empty Value, so nothing else
changes.

Testing

  • go test -count=1 ./cue/cuex/ and make unit-test (full suite with envtest)
  • golangci-lint run ./... with the pinned 1.60.1 from makefiles/const.mk (0 issues)
  • gofmt and go vet
  • The added tests fail against the current code and pass with the change. The
    NewFunctionCallError case asserts the message does not contain cue/format, which is the exact
    string from the report.

AI assistance

Claude Code helped with this change and the tests. I reviewed the result and checked the behavior
myself with the test suite and linters.


Summary by cubic

Fixes function call error messages so they omit empty paths and unrenderable values, removing misleading output like function call error for : and (value: cue/format: unsupported node type <nil>). This addresses the error messages seen in kubevela/kubevela#7365. Messages that include both a path and a value are unchanged. The exported FunctionCallError.Value field is now empty when the value can't be rendered, but only internal cue/cuex code uses it. Note: a go.mod bump in kubevela/kubevela is still needed before the fix reaches users.

Written for commit 1f3eff9. Summary will update on new commits.

Review in cubic

somaz94 added a commit to somaz94/somaz94 that referenced this pull request Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.71%. Comparing base (a4214d8) to head (1f3eff9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
+ Coverage   88.62%   88.71%   +0.09%     
==========================================
  Files          95       95              
  Lines        4985     4991       +6     
==========================================
+ Hits         4418     4428      +10     
+ Misses        373      371       -2     
+ Partials      194      192       -2     
Flag Coverage Δ
unit-test 88.71% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@somaz94
somaz94 marked this pull request as ready for review September 8, 2026 08:25

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant