Giter Club home page Giter Club logo

Comments (5)

mholt avatar mholt commented on May 21, 2024

(Known issue - the line number in the panic message is +2 the actual, so line 64 is actual source of panic. Still not sure why the line number is off.)

I thought I fixed this with commit 8ea98f8 - have you pulled the latest recently? (go get -u github.com/mholt/caddy should do it)

from caddy.

mschoebel avatar mschoebel commented on May 21, 2024

Unfortunately, I get the described effect with the latest HEAD ...

I added debug statements to the load method (metadata.go) ...

func (m *Metadata) load(parsedMap map[string]interface{}) {
    fmt.Printf("-- %v\n", parsedMap)
    if template, ok := parsedMap["title"]; ok {
        m.Title, _ = template.(string)
    }
    if template, ok := parsedMap["template"]; ok {
        m.Template, _ = template.(string)
    }
    if variables, ok := parsedMap["variables"]; ok {
        fmt.Printf("-- %v\n", reflect.TypeOf(variables))
        vars, ok := variables.(map[string]interface{})
        m.Variables = vars
        fmt.Printf("-- %v - %v\n", vars, ok)
    }
}

... and get the following output:

(YAML)

-- map[template:default variables:[map[title:Test]]]
-- []interface {}
-- map[] - false

(TOML)

-- map[template:default variables:map[title:Test]]
-- map[string]interface {}
-- map[title:Test] - true

yaml.Unmarshal (in Parse of YAMLMetadataParser) seems to return something unexpected.

I might have some more time tomorrow for more debugging.

from caddy.

abiosoft avatar abiosoft commented on May 21, 2024

Thanks for testing this out.

I have seen the issue, the fix should be out soon.

Firstly, the YAML syntax used for variables - is for a list and not an object. Only indentation is the requirement for a nested objected. (I am also guilty of this).

Should be

 ---
  template: default
  variables:
    title: Test
  ---

Secondly, the yaml package decodes nested maps into a map[interface{}]interface{} and I was assuming a map[string]interface{}.

Thanks.

from caddy.

abiosoft avatar abiosoft commented on May 21, 2024

@mschoebel The fix has been merged. Let us know if it works now.

Thanks.

from caddy.

mschoebel avatar mschoebel commented on May 21, 2024

Works. 👍

YAML is weird.

from caddy.

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.