Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Invalid YAML: inconsisten indentation

  1. #11
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Invalid YAML: inconsisten indentation

    Quote Originally Posted by kotgc View Post
    Thanks, all fixed. I like the 4 space indent to fool proof these errors OR perhaps the 2 YAML code checker websites might do it.
    It is easily possible to have invalid YAML for a specific config, yet pass YAML validators. YAML is better for humans than json and xml, but not as good as the old inifile format that humans have been trained to understand. Sigh.

    Wish there were a format that was both good for computers to parse AND good for humans. I have an idea, perhaps like the format in the /etc/network/interfaces file? Crazy idea, but we used that for many decades and having 1 extra space didn't break everything. Distros that push YAML should rethink their audience needs.

  2. #12
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    7,701

    Re: Invalid YAML: inconsisten indentation

    Glad that's OK.
    There is a program called yamllint in the repositories. Just say "yamllint <filename>" and it will pour criticism on your creation. In theory a yaml document should begin with a line of three dashes, but most people don't bother. It bitches about that though.

    Of course, it's possible to have valid YAML that doesn't make sense in context, such as where bridges was another ethernet interface or routes was a property of bridge br1.

    @TheFu: I don't think INI files were able to do nested structures though. I suppose dotting everything might be an option, like:
    Code:
    network.ethernets.enp2s0.dhcp4 : false
    network.ethernets.enp2s0.dhcp6 : false
    network.ethernets.enp2s0.link-local : []
    network.ethernets.enp3s0.dhcp4 : false
    network.ethernets.enp3s0.dhcp6 : false
    network.ethernets.enp3s0.link-local : []
    network.bridges.br0.interfaces: [enp3s0]
    but to be honest, I prefer YAML to that.

    I have to say, I don't understand the structure that I posted above - it seems that both Ethernet interfaces are also bridge interfaces and that doesn't make sense to me. Maybe it means the ethernet interfaces are connected to the bridges? One day I'll look that up, but right now breakfast is more urgent.
    Last edited by The Cog; December 3rd, 2023 at 11:40 AM.

  3. #13
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Invalid YAML: inconsisten indentation

    Quote Originally Posted by The Cog View Post
    ...
    I have to say, I don't understand the structure that I posted above - it seems that both Ethernet interfaces are also bridge interfaces and that doesn't make sense to me. Maybe it means the ethernet interfaces are connected to the bridges? One day I'll look that up, but right now breakfast is more urgent.
    Before XML existed, I wrote code to support import/export of non-trivial data structures with 5-levels of nesting for a commercial product. It was custom, but used iniFile as the basis. Nested objects were allowed in any order, since the code would parse it all and layout the relationships before creating all the DB objects. Our clients and support people had no problems understanding the required parent-child relationships. Within the file to be imported, the connections between parent and child object had to be consistent, but wasn't used literally inside the system to make connections. We used orefs for that. Object-References are like a "Class::Sequence" way of looking at individual computer objects. Every object of the same class would begin with the same 6 characters. System objects would have sequences less than 10,000 and end-user objects had sequences that started at 10,001 but effectively had no limit ... (4 billion?) Running out was never considered possible and we never saw it happen.

    Anyway, it wasn't exactly thrilling code. Think of detailed parts books and being able to setup a DBMS schema to allow importing millions of different part types, many similar, but many completely different. The attributes for those parts are provided in books that look like the old phone books on very thin paper. Average people come across these perhaps at the autostore when they look up the replacement air and oil filter for their cars. Those are just 2 parts. Imagine you are a business and sell "things" using over a million different parts. Your engineering teams need to know what parts are available, from whom, and what all the attributes are for each part. How many sizes and types of screws are there in the world?

    I can't imagine how hard it would have been to force the non-technical clients to learn the intricacies of YAML whitespace requirements. Whitespace requirements seem like a good idea until you see someone non-technical trying to figure it out themselves. I've written parsers that needed to handle any input a human might decide to throw at it. Machine to machine communications is like an airliner autopilot, but when humans get involved, it is more like self-driving vehicles in a constantly changing city. autopilots are relatively simple compared to self-driving on city streets with humans trying to screw with the algorithm of the machine. Pilots are trained to only provide very, specific, approved, inputs to their plane. Humans outside flying planes control spacing to ensure slight location mistakes don't cause crashes. The more dense the planes are in an area, the more tightly controlled where, when, how fast, they are allowed to fly. If only YAML were like that.

    Let machines have their method for configs and let humans have their own. Machines can export/import xml/json/yaml no problem. Of those 3, yaml is the easiest for humans to modify. I have some web servers that will output html, xml, json, or yaml, based on what is requested by the client. It is handy for RESTful client/server needs for APIs that are automatically available. We have sfdisk for machines to dump their partitions to machine-readable text. We have fdisk for humans.

    Anyway, there are lots of precedents already.

    A shower is more urgent to me, and everyone around here, than b'fast.

  4. #14
    Join Date
    Apr 2023
    Beans
    95

    Re: Invalid YAML: inconsisten indentation

    Replying to post #4 TheFu, yes, the link-local: [] line can be deleted. I tested and works fine.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •