GithubHelp home page GithubHelp logo

Comments (5)

ericdand avatar ericdand commented on July 22, 2024

Code tracing: the first line of the error message is reported in daisy.go#main(), specifically around line 197, within if err:= w.Run(ctx);. Digging into workflow.go#Run(ctx), it calls Validate(ctx), which contains the string "error populating workflow". Validate(ctx) calls populate(ctx), which in turn calls populateStep(ctx, step), which finally calls step.go#stepImpl(), the source of the string "no step type defined". So that's where all the parts of this error message come from.

Before the workflow is run, however, it is unmarshalled from a JSON object. This includes unmarshalling all of its steps. This happens in workflow.go#readWorkflow(file, w). Unfortunately, it looks like invalid step types are simply ignored. https://golang.org/pkg/encoding/json/#Unmarshal says:

To unmarshal JSON into a struct, Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match. Unmarshal will only set exported fields of the struct.

Furthermore:

If a JSON value is not appropriate for a given target type ... Unmarshal skips that field and completes the unmarshaling as best it can.

So, as it stands, misspelled step types are just dropped silently on the floor.

But there is hope:

To unmarshal JSON into a value implementing the Unmarshaler interface, Unmarshal calls that value's UnmarshalJSON method, including when the input is a JSON null. Otherwise, if the value implements encoding.TextUnmarshaler and the input is a JSON quoted string, Unmarshal calls that value's UnmarshalText method with the unquoted form of the string.

So, if we add an UnmarshalJSON method to our Workflow type, then we could do the error checking. I'm yet unsure how much work this would take.

from compute-image-tools.

ericdand avatar ericdand commented on July 22, 2024

After further consideration, I have two conclusions:

  1. It makes more sense to only make Step implement the Unmarshaler interface, and
  2. It does indeed make sense, given the funny way we represent steps (specifically their type) in JSON, to write custom unmarshalling logic for steps.

Happily, to implement Unmarshaler, it only takes one method. I'll get right to it.

from compute-image-tools.

adjackura avatar adjackura commented on July 22, 2024

See this, should be in go 1.10:
https://go-review.googlesource.com/c/go/+/74830

from compute-image-tools.

ericdand avatar ericdand commented on July 22, 2024

Awesome! Alright, I'll just wait until that's released, then we can use that.

from compute-image-tools.

crunk1 avatar crunk1 commented on July 22, 2024

Partial fix out: #255

Reports the offending step name when there is a step population error.

from compute-image-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.