Skip to content

Some cue errors are not caught before running #493

Closed

Description

@shykes

One big selling point of Cue is that you can catch many errors in your configuration before applying it. However, certain errors which should be caught before running (or at least feel like they should be caught), are not.

So far I have identified one category of errors which is not caught by Cue before execution:

  • References to a non-existing definition in an imported package

For example, I expect this snippet to fail before execution, but it does not:

import (
   “strings” // Package name does not matter. Builtin or external package doesn’t matter.
)

// #Nope field does not exist in the package
foo: strings.#Nope

In summary, references to non-existing fields in another package are not considered an error at build time, but will in fact resolve to an error when queried at run time.

Related

Activity

  1. added this to the beta milestone on May 25, 2021
  2. shykes commented on May 25, 2021

    @shykes
    ContributorAuthor

    Copying @aluzzardi @mpvl @myitcv . We have discussed this one before - I’m just documenting it to make sure we don’t forget it.

  3. myitcv commented on May 25, 2021

    @myitcv
    Contributor

    Here is a link to the CUE issue tracking this cue-lang/cue#629

  4. modified the milestones: v0.1.0, on Jan 7, 2022
  5. removed their assignment
    on Jan 7, 2022
  6. modified the milestones: , next on Feb 1, 2022
  7. aluzzardi commented on Feb 2, 2022

    @aluzzardi
    Contributor
  8. aluzzardi commented on Feb 2, 2022

    @aluzzardi
    Contributor

    Moving this to 0.2.x since there's not much we can do but wait for an upstream fix.

  9. modified the milestones: next, on Feb 2, 2022
  10. 19 remaining items

  11. mircubed commented on Jun 28, 2022

    @mircubed
    Contributor
  12. helderco commented on Jul 5, 2022

    @helderco
    Contributor

    The issue from that comment is the error you get when you mistype the following:

    client: filesystem: ".": read: contents: dagger.FS

    The expected error would be:

    failed to load plan: client.filesystem.".".read.contents: undefined field: FS

    But what you see is:

    failed to load plan: "client.filesystem.\".\".read" is not set

    The reason is that validation is being done from top down. First on client, then client: filesystem, etc... When it reaches client: filesystem: ".": read it's not concrete because the read: contents field is a disjunction that isn't resolved due to the undefined field (typo).

    In fact, if you look closely into the incomplete cause disjunction error, you can see the error buried in there:

    ERROR system | failed to load plan: "client.filesystem.\".\".read" is not set
    actions.test.undefinedAction.input: unresolved disjunction 
    {contents:_|_(client.filesystem.".".read.contents: incomplete cause disjunction),
    $dagger:{task:{_name(dagger.io/dagger):"ClientFilesystemRead"}},path:*"." | string} | 
    {contents:_|_(client.filesystem.".".read.contents: undefined field: FS),
    $dagger:{task:{_name(dagger.io/dagger):"ClientFilesystemRead"}},path:*"." | string} (type struct)
    

    I think we need to prioritize at least undefined field errors since they're clearly a cause for other errors upper in the tree, and it's easier for the user to get to that root cause.

  13. removed their assignment
    on Aug 9, 2022
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

    kind/bugkind/user-request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions