• Tja@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        3 hours ago

        Akcshually we use 0 and “not equal 0”, since “not 0” would be 0xFF…FF, and (at least gcc) gives back a 1 for a true expression. No idea about the spec, probably undefined…

  • pHr34kY@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    7 hours ago

    The backend and frontend on the product I work on are like this.

    As long as you remember that booleans are not strings and should always be parsed if they are, this won’t be a problem.

    I am yet to see a boolean.parse() implementation in the wild that is case sensitive.

  • fibojoly
    link
    fedilink
    arrow-up
    19
    ·
    17 hours ago

    Glorious. I remember some hilarious nonsense in an API where the devs I worked with hadn’t known they could just use boolean in JSON and had badly implemented it through strings, but this… This is amazing!

    • jimmux@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      8 hours ago

      At my last job we had a lot of old code, and our supposedly smartest framework people couldn’t be bothered learning front end properly. So there was a mix of methods for passing values to the front end, but nobody seemed to think of just passing JSON and parsing it into a single source of truth. There was so much digging for data in hidden columns of nested HTML tables, and you never knew if booleans would be “true”, “TRUE”, “1”, or “Y” strings.

      Never mind having to unformat currency strings to check the value then format them back to strings after updating values.

      I fixed this stuff when I could, but it was half baked into the custom framework.

    • sushibowl@feddit.nl
      link
      fedilink
      arrow-up
      1
      ·
      6 hours ago

      A system I work with gives all keys a string value of “Not_set” when the key is intended to be unset. The team decided to put this in because of a connection with a different, legacy system, whose developers (somehow) could not distinguish between a key being missing or being present but with a null value. So now every team that integrates with this system has to deal with these unset values.

      Of course, it’s up to individual developers to never forget to set a key to “Not_Set”. Also, they forgot to standardise capitalisation and such so there are all sorts of variations “NOT_SET”, “Not_set”, “NotSet”, etc. floating around the API responses. Also null is still a possible value you need to handle as well, though what it means is context dependent (usually it means someone fucked up).

    • owl@infosec.pub
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      13
      ·
      21 hours ago

      To me the biggest problem, that AI might solve is documentation.

        • Hupf@feddit.org
          link
          fedilink
          arrow-up
          9
          arrow-down
          1
          ·
          edit-2
          8 hours ago

          Have you tried to use AI for <thing>? It’s pretty shit.

          • Tja@programming.dev
            link
            fedilink
            arrow-up
            3
            ·
            6 hours ago

            Translation, proofreading, summarizing, brainstorming, boilerplate code, protein folding…

            • stetech@lemmy.world
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              5 hours ago

              protein folding

              We’re at the point where, due to how b2c tech services work, I think a lot of people think AI === LLM

        • milicent_bystandr@lemm.ee
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          18 hours ago

          I’ve used AI to give me a good enough guess that I know the right keywords to search for too find the real documentation.

        • thedeadwalking4242@lemmy.world
          link
          fedilink
          arrow-up
          4
          arrow-down
          3
          ·
          21 hours ago

          I’ve had pretty good experience with using AI to find what I’m looking for in documentation, especially if the docs are in context

          • SatyrSack@feddit.org
            link
            fedilink
            English
            arrow-up
            15
            ·
            20 hours ago

            I think they mean having an AI read code and then write documentation for it. Not having an AI read documentation.

  • Lucy :3@feddit.org
    link
    fedilink
    arrow-up
    171
    ·
    edit-2
    1 day ago

    So we need to be careful with upper- and lowercase. Meanwhile the docs: > settiings

  • jjjalljs@ttrpg.network
    link
    fedilink
    arrow-up
    87
    arrow-down
    2
    ·
    1 day ago

    Is the backend Python and the frontend JavaScript? Because then that would happen and just be normal, because Boolean true is True in python.

    • testfactor@lemmy.world
      link
      fedilink
      arrow-up
      129
      arrow-down
      2
      ·
      1 day ago

      Probably, but if you’re interpreting user inputs as raw code, you’ve got much much worse problems going on, lol.

        • MajorHavoc@programming.dev
          link
          fedilink
          arrow-up
          14
          ·
          24 hours ago

          Hey, that’s my username too. Or it was going to be, while the site was still up.

          What a coincidence!

          I guess I’ll wait for the site to come back, and see if it’s still available…

      • mmddmm@lemm.ee
        link
        fedilink
        arrow-up
        19
        arrow-down
        3
        ·
        1 day ago

        It’s the settiings file… It’s probably supposed to only be written by the system admin.

        • raldone01@lemmy.world
          link
          fedilink
          arrow-up
          9
          arrow-down
          1
          ·
          edit-2
          1 day ago

          A good place to put persistent malware. That’s why when using docker images always mount as ro if at all possible.

          • Ashley@lemmy.ca
            link
            fedilink
            arrow-up
            8
            ·
            1 day ago

            It’s you can modify the settings file you sure as hell can put the malware anywhere you want

          • mmddmm@lemm.ee
            link
            fedilink
            arrow-up
            3
            ·
            1 day ago

            Every environment has plenty of good places to put persistent malware. Even if you run your docker images as ro.

      • Given the warning about capitalization, the best possible case is that they’re using ast.literal_eval() rather than throwing untrusted input into eval().

        Err, I guess they might be comparing strings to ‘True’ and are choosing to be really strict about capitalization for some reason.

        • palordrolap@fedia.io
          link
          fedilink
          arrow-up
          5
          ·
          19 hours ago

          In this instance, I think there was some suggestion to write code in mostly lower case, including all user variables, or at least inCamelCaseLikeThis with a leading lower case letter, and so to make True and False stand out, they’ve got to be capitalised.

          I mean. They could have been TRUE and FALSE. Would that have been preferable? Or how about a slightly more Pythonic style: __true__ and __false__

          • jdeath@lemm.ee
            link
            fedilink
            arrow-up
            4
            ·
            17 hours ago

            i would go with lowercase and just have it be a reserved word like the other ones. but I’m not super picky, i generally like to stick to what people are used to, and i can understand the reasoning behind the choice.

      • PotatoesFall@discuss.tchncs.de
        link
        fedilink
        arrow-up
        24
        ·
        1 day ago

        Yep they should use a config file format like JSON or TOML or YAML or what have you, and then decode that into python objects. Using an actual programming language for config is dumb as hell IMO. (inb4 pissed off suckless fans)

      • jjjalljs@ttrpg.network
        link
        fedilink
        arrow-up
        5
        ·
        1 day ago

        Depends on how it’s set up. If the setting is going into the env it’s a string, so I’d expect some sort of

        if os.getenv("this_variable", "false").lower() == "true":   # or maybe "in true, yes, on, 1" if you want to be weird like yaml
          this_variable = True
        else:
          this_variable = False
        

        Except maybe a little more elegant and not typed on my phone.

        But if the instructions are telling the user to edit the settings directly, like where I wrote this_variable=True, they’d need to case it correctly there.

        • Fushuan [he/him]@lemm.ee
          link
          fedilink
          arrow-up
          2
          ·
          20 hours ago

          Fyi, using a condition to assign a boolean is equivalent to assigning the condition itself. No need for the IF.

          • jjjalljs@ttrpg.network
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            18 hours ago

            true, though sometimes i find the more verbose style easier to read, and more maintainable (eg: you want to do something else in the block, you can just add a line instead of changing your ternary / etc). Small things

  • ramble81@lemm.ee
    link
    fedilink
    arrow-up
    12
    arrow-down
    2
    ·
    21 hours ago

    I’ve always hated case sensitivity. I know that at an ASCII level “variable” != “Variable” but is there really a reason to have a distinction between them?

    • fibojoly
      link
      fedilink
      arrow-up
      16
      arrow-down
      1
      ·
      17 hours ago

      You are thinking it’s easy because you only think of e == E, but I’ll let you look up collation and accents and, you know, Unicode and let you think about it.

      There is nothing trivial about case sensitivity, except in trivial cases.

    • vithigar@lemmy.ca
      link
      fedilink
      arrow-up
      18
      ·
      20 hours ago

      You stated the reason yourself. Those are different values and matching in a case-insensitive manner is more work under the hood.

      • ramble81@lemm.ee
        link
        fedilink
        arrow-up
        8
        arrow-down
        3
        ·
        20 hours ago

        We do plenty of stuff for human consumption. Computers work for us, not the other way around. Insensitivity should be the default. It’s okay to give options. I’m not saying take that away.

        • calcopiritus@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          20 hours ago

          For some reason we decided that a lot of formats written by computers and read by computers would use ASCII encoding instead of raw data.

          Making a json or XML deserializer case insensitive would just make it slower for almost 0 benefit.

  • Aurenkin
    link
    fedilink
    arrow-up
    32
    ·
    1 day ago

    The cherry on top is that they didn’t even spell settings correctly.

    • themaninblack@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      16 hours ago

      I swear, spelling mistakes are such an indicator for a codebase and the overall quality of the software team, and maybe the whole company. No attention paid to detail leaks out into other areas.

    • MajorHavoc@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      24 hours ago

      I like your idea, but hear me out:

      A Python file for configuration is the best way to guarantee that any friendly code I write to help the user with config usually won’t execute. And I hate my users.