News for hackers. Stuff that matters.
Re:A routine gem update ended up creating $73k worth of subs... by ricardobeat on Friday January 07, 2022 @05:59PM (#29846105)
That sounds like a major, incredibly dangerous update to the DB driver. Their 7.1, 7.2, 7.3 versions seem to all have breaking changes [1].

Yet they are in obvious violation of SemVer expectations, which they declare to follow [2]:

> Mongoid follows versioning guidelines as outlined by the Semantic Versioning Specification, so you can expect only backwards incompatible changes in major versions [sic]

[1] https://docs.mongodb.com/mongoid/current/tutorials/mongoid-u...

[2] https://mongoid.github.io/old/en/mongoid/docs/upgrading.html

Re:A routine gem update ended up creating $73k worth of subs... by dragonwriter on Friday January 07, 2022 @06:42PM (#29846587)
> Mongoid follows versioning guidelines as outlined by the Semantic Versioning Specification, so you can expect only backwards incompatible changes in major versions

I will note that this reverses the direction of implications.

In SemVer, you should expect breaking changes only in major versions. (All version changes with breaking changes should be major, but nonbreaking changes can occur in major or minor versions.)

This is not the same as expecting only breaking changes in major versions. (Which would mean all changes in major versions should be breaking, nonbreaking changes cannot occur in major versions, and breaking changes might still occur in minor versions.) .

Re:A routine gem update ended up creating $73k worth of subs... by munificent on Friday January 07, 2022 @06:48PM (#29846641)
I'm guessing the sentence they wrote is just a consequence of English not being the author's primary language. I frequently see ESL speakers get adjective and adverb positions wrong in ways that unintentially change the meaning.

Even skilled English speakers make mistakes here because English is both very permissive about word order, but also tends to give different shades of meaning to each other. "Only" is a pernicious one. When I got my last book copyedited, fixing the location of "only" was one of the most common changes.

Re:A routine gem update ended up creating $73k worth of subs... by egeozcan on Saturday January 08, 2022 @02:41AM (#29849554)
Reminds me the "any cars that have been lapped by the leader will be required to pass the cars on the lead lap and the safety car" clause in the Formula 1 racing regulations (article 48.12), which got a lot of attention after the last race in the season.

Red Bull Racing argued that in that sentence "any" doesn't mean "all". As a non-native speaker, this is just mind games for me.

More reading: https://english.stackexchange.com/questions/580131/does-any-...

If you really have a lot of free time, interest in regulations, F1 AND the English language, this deep dive can also be interesting: https://www.reddit.com/r/F1Technical/comments/rkv633/unpacki...

Re:A routine gem update ended up creating $73k worth of subs... by BucketsMcG on Saturday January 08, 2022 @06:34AM (#29850700)
I'm a native English speaker with a degree in linguistics, but I didn't appreciate how hard "some/any" are for native speakers until a Polish colleague asked me to explain it, and I pretty much failed. It's something you learn how to do intuitively, but when you try to formulate a consistent set of rules explaining why you choose one over the other, it turns out to be pretty difficult.
Re:A routine gem update ended up creating $73k worth of subs... by SOLAR_FIELDS on Saturday January 08, 2022 @03:57PM (#29856158)
A decent amount of English is full of inconsistencies like this. Every language has its warts, of course, but like you I never really realized how difficult English is as a language until asked to explain certain behaviors to non-native speakers.
Re:A routine gem update ended up creating $73k worth of subs... by jzwinck on Friday January 07, 2022 @07:02PM (#29846796)
There is a real parallel between this mistake and the or() mistake. As a native English speaker I glossed over both of them at the first reading.
Re:A routine gem update ended up creating $73k worth of subs... by thaumasiotes on Friday January 07, 2022 @07:57PM (#29847334)
> When I got my last book copyedited, fixing the location of "only" was one of the most common changes.

I remember a puzzle which presented a (fairly long) sentence and asked "provide a word that can be correctly inserted at any point in this sentence".

The answer was "only". (Of course the meaning would change according to where the "only" was placed, but still... you'd have a hard time inserting "experience" at every position of a sentence.)

Re:A routine gem update ended up creating $73k worth of subs... by JimDabell on Saturday January 08, 2022 @12:05AM (#29848791)
In case anybody is wondering, the sentence normally given as an example of this is “She told him that she loved him”. You can put the word “only” anywhere in that sentence and each position makes the sentence mean something different.
Re:A routine gem update ended up creating $73k worth of subs... by thaumasiotes on Saturday January 08, 2022 @12:49PM (#29854131)
As a technicality, while it's possible for "she only told him that she loved him" and "she told him only that she loved him" to mean different things, it's also possible for them to mean the same thing.

(And in fact, the primary meaning of the first sentence is the one identical to the meaning of the second - you can read it "she only told him that she loved him [and she didn't do anything else]", but by default you'll read it "she only told him that she loved him [and she didn't tell him anything else]".)

The reason for the ambiguity is that the verb is the head of the sentence, and so an "only" placed to scope over the verb has several different options for where the scope "really is".

Re:A routine gem update ended up creating $73k worth of subs... by philwelch on Saturday January 08, 2022 @01:25AM (#29849145)
It’s kind of like the saying, “all that glitters is not gold”. Gold doesn’t glitter? That makes no sense.

English syntax is not mathematical logic. The song, “I Can’t Get No Satisfaction” is not a song about someone who is forced to receive satisfaction.

Re:A routine gem update ended up creating $73k worth of subs... by dagmx on Saturday January 08, 2022 @03:08AM (#29849696)
Somewhat related to your points of music...

There's an episode of "This is Pop!" on Netflix that explores why the Swedes write so many pop hits.

One of the arguments presented is that they speak English well as a second/third language so they're less focused on the lyrics making sense and being grammatically correct, and are free to make lyrics that sound like they work but are non-sensical on reflection. It's just the right amount of separation from the language.

Ever since I saw that, I've been listening closer to a lot of the top pop songs over the last decade, and it's fascinating how English is so breakable while sounding right to our mind, but falls apart under scrutiny. (Obviously this is not unique to the swedish writers, even people who only speak English do it as well)

Re:A routine gem update ended up creating $73k worth of subs... by wincy on Saturday January 08, 2022 @03:58AM (#29849917)
The song “I want it that way” comes to mind, the song topped many charts including in the US, and the lyrics are very strange upon reflection. What does “I never wanna hear you say. I want it that way.” mean exactly? Apparently the Swedish songwriter barely spoke any English at all at the time.
Re:A routine gem update ended up creating $73k worth of subs... by dagmx on Saturday January 08, 2022 @11:17AM (#29853059)
That's actually one of the songs that's mentioned, as well as Oops I Did It Again by Britney and Hit Me Baby One More Time

Even more recently, Shake it Off by Taylor Swift.

Somewhat along the same lines, I was watching the Get Back documentary on the Beatles and the number of songs they write by effectively scatting and then filling in the words that were their big hits is amazing.

Again they're writing to fit the tune, then in filling the words based on a general theme. It's very different than the songs they write where you can tell someone's sat down and written the words first.

Re:A routine gem update ended up creating $73k worth of subs... by rightbyte on Saturday January 08, 2022 @06:58AM (#29850837)
>> I never wanna hear you say, "I want it that way" <<

Probably?

Re:A routine gem update ended up creating $73k worth of subs... by derefr on Saturday January 08, 2022 @01:39AM (#29849229)
A lot of the confusion in English can be relieved, sometimes, by flipping clauses around. “All that glitters / is not / gold” ⇒ “gold / is not / all that glitters.”
Re:A routine gem update ended up creating $73k worth of subs... by cobaltoxide on Saturday January 08, 2022 @01:32AM (#29849191)
I guess Shakespeare did write it that way, but I've always heard the saying as "Not all that glitters is gold." Perhaps he took some poetic license at the expense of logical correctness.
Re:A routine gem update ended up creating $73k worth of subs... by dragonwriter on Saturday January 08, 2022 @05:27AM (#29850309)
> Shakespeare […] Perhaps he took some poetic license

That was kind of his thing, when he wasn’t just inventing words to fit rhyme/meter/mood.

He’s not who you would go to if you wanted unambiguous documentation of the guarantees you were providing downstream users, that wasn’t really his thing.

Re:A routine gem update ended up creating $73k worth of subs... by mananaysiempre on Saturday January 08, 2022 @11:35AM (#29853262)
> English syntax is not mathematical logic

Open any book or paper on semantics (the linguistics kind, not the philosophy or the early-20th-century pseudoscience kind) and you might be surprised :) It’s just that the logic is not that straightforward to get out, and of course there’s semantics (the literal meaning, where “Can you pass the salt?” is a question about ability) and then there’s pragmatics (the thing one is actually trying to communicate, where “Can you pass the salt?” is a request with certain degrees of respect and formality attached to it).

> “I Can’t Get No Satisfaction”

This is probably not a very good example as it’s just (AFAIU) not strictly “standard English” in that it exhibits negative concord absent from the standard grammar (for dramatic effect, although “We Don’t Need No Education” is probably a better case). That is to say, this is a phrase in a language (which is very similar to standard English but not quite the same) where the grammar requires dummy negations on complements of negative verbs—a purely syntactic thing that doesn’t even reach the layer of semantics / logic.

But then many other varieties of English do that (I remember reading somewhere that the dialect that gave rise to the current standard is actually somewhat unusual among other dialects in that respect), so does my native Russian (and other Slavic languages, and some but not all Romance ones), and Japanese actually requires you to negate the adjective when using the adverb meaning “hardly, not very”[1] while at the same time using some double negations as polite affirmations[2].

[1] https://japanese.stackexchange.com/q/18006

[2] https://www.nhk.or.jp/lesson/english/teacher/36.html

Re:A routine gem update ended up creating $73k worth of subs... by ay on Saturday January 08, 2022 @07:39AM (#29851116)
It’s curious that a Russian version is much more precise:

“Not everything that glitters is gold”. (The truly 1:1 translation is “not everything is gold that glitters” but that word order felt very wrong and I believe the change doesn’t change the meaning, does it ?)

How does it sound for a native speaker ?

Re:A routine gem update ended up creating $73k worth of subs... by mannykannot on Saturday January 08, 2022 @08:32AM (#29851503)
I am a native speaker of English, yet my knowledge of its grammar is almost entirely informal. Having said that, it seems to me that in the 1:1 translation, the object of ‘is’ is ‘gold that glitters’, rather than just ‘gold’, and its subject is ‘everything’ rather than ‘everything that glitters’, and that these are semantic differences, as the intended meaning is specifically about things that glitter. I hope someone more knowledgable can cite the relevant rules here, whether for or against this reading.

To avoid ambiguity (whether actual or merely perceived by me), I might say “Just because something glitters, it need not be gold”, but that is not much of an aphorism!

Re:A routine gem update ended up creating $73k worth of subs... by deviantintegral on Friday January 07, 2022 @08:54PM (#29847739)
They may actually mean what they say. It’s not uncommon for projects to release the last minor version at the same time as the next major. For example, Drupal 9.0.0 was functionally equivalent to Drupal 8.9.0, except 9.0 had all deprecations dropped. New 9.0+ only features didn’t show up until 9.1.
Re:A routine gem update ended up creating $73k worth of subs... by kortex on Friday January 07, 2022 @09:22PM (#29847939)
Yeah, that is probably the smart way to do it. Frontload all of your necessary new features in 8.9/9.0-dev (so you can complete the deprecations), roll over the major and remove only the deprecated code paths without introducing any new ones.
Re:A routine gem update ended up creating $73k worth of subs... by Gigachad on Saturday January 08, 2022 @01:07AM (#29849060)
Tbh when you work with ruby to have to assume everything could break with any update and just unit test the shit out of everything. Of course it’s easy to miss something, but unit tests could have caught this issue.

It's still just really bad work from the gem developers though. Ideally you shouldn't ever drastically change the behavior of a method. Just introduce it again with a new name and remove the old one. Yeah it might not be as nice, but it avoids triggering $73,000 worth of incorrect transactions.

Re:A routine gem update ended up creating $73k worth of subs... by emodendroket on Saturday January 08, 2022 @01:25AM (#29849150)
Ultimately this is why I don't like to work in Ruby. You can just never trust any line of code between the gem updates, the unhelpful signatures, the overreliance on hashes everywhere, and a million different levels of mix-ins and indirection. Yeah, it's expressive, but how much time are you really saving once you consider all these maintenance headaches?
Re:A routine gem update ended up creating $73k worth of subs... by ljm on Saturday January 08, 2022 @05:27AM (#29850312)
We're just trading anecdotes at this point but I can't say I've encountered the same problems over the past decade of working with it. That's generally because of limiting dependencies, but also because it's a good idea to peek at the changelog or release notes when bumping the minor or major version.

TFA doesn't mention or acknowledge this aspect of the issue, but it did surprise me that they considered a version bump from 7.0.8 to 7.3.3 to be innocent looking.

In fact, these 'minor' releases actually appear to be quite significant and the issue in question in TFA was explicitly documented. [0][1]

I hate to say it but this was just a case of sloppy work on the startup's part. It took me less than 5 minutes to find that info.

[0] https://docs.mongodb.com/mongoid/current/tutorials/mongoid-u... [1] https://github.com/mongodb/mongoid/releases/tag/v7.1.0

Re:A routine gem update ended up creating $73k worth of subs... by newaccount74 on Saturday January 08, 2022 @06:58AM (#29850836)
It took you 5 minutes to find the info because you knew what you were looking for.

Expecting programmers to audit all of their code before a minor update is ridiculous.

Re:A routine gem update ended up creating $73k worth of subs... by ljm on Saturday January 08, 2022 @08:25AM (#29851439)
'Auditing all your code' isn't the same as looking up the changes for a certain version on its github release page or a changelog page (if it has one).

It's not the responsibility of OSS maintainer to ensure your software still functions after an upgrade if you're not even willing to spend a modicum of effort to hold up your own end of that bargain. This isn't a big ask, it's why there are changelogs and release notes in the first place; they make it so you don't have to audit the code every time the version changes.

If you're not willing to do that and want unattended upgrades for all dependencies, then this is where the 'no warranty' aspect of that OSS license comes in.

Re:A routine gem update ended up creating $73k worth of subs... by Gigachad on Saturday January 08, 2022 @04:34PM (#29856548)
>It's not the responsibility of OSS maintainer

The OSS maintainer has no responsibilities at all so you are right. But if anyone was to blame, it's certainly the library. It's outrageous to radically change a function while keeping the name the same. Because of exactly this issue. If they renamed it you would get an exception which is much nicer.

Re:A routine gem update ended up creating $73k worth of subs... by losvedir on Saturday January 08, 2022 @09:18AM (#29851869)
Seriously? It's eminently reasonable to expect you to know the code you're deploying. Perhaps you're a JS developer. I agree it's incredibly difficult to keep up with the churn there, but in my Elixir deps, the updates tend to be less frequent and more reviewable.

Some deps you can trust the owner and just carefully review the change log. Even that would have caught this issue, though I'm not sure I'd count this gem as trustworthy.

Re:A routine gem update ended up creating $73k worth of subs... by newaccount74 on Saturday January 08, 2022 @12:33PM (#29853915)
I'm not a JS developer, I'm just someone who has shipped enough software to know that the fraction of people reading change logs is vanishingly small.

Maybe you are a very careful developer, but the vast majority out there is not.

Shipping an udate that will corrupt data if you don't read the changelog is very very dangerous.

I see why they did it. Having a method with the same name as in Active Record but with different behavior is also dangerous.

But they really could have handled this better.

Re:A routine gem update ended up creating $73k worth of subs... by blindmute on Saturday January 08, 2022 @12:33PM (#29853908)
I'd say that updating any version of anything, without reading the changelog, is irresponsible. Why are you updating a gem if you have no idea what has changed?
Re:A routine gem update ended up creating $73k worth of subs... by emodendroket on Saturday January 08, 2022 @02:47PM (#29855428)
In other programming environments people do this without issue routinely.
Re:A routine gem update ended up creating $73k worth of subs... by ljm on Saturday January 08, 2022 @04:31PM (#29856511)
I used to do this, especially with patch releases. Just bump the version and hope the build passes. My mindset has gradually shifted over time though.

These days, it's more a case of updating one thing at a time, and doing the research up front to see what I'm gaining from it or if I might as well stay on the current version. No point updating for the sake of it.

That's 5-10 minutes of up-front, preventative effort that might otherwise become hours of reactive firefighting, and as much time spent on damage control, if it got into production unchecked.

Re:A routine gem update ended up creating $73k worth of subs... by ricardobeat on Saturday January 08, 2022 @10:38AM (#29852639)
The NPM mindset.
Re:A routine gem update ended up creating $73k worth of subs... by phendrenad2 on Sunday January 09, 2022 @08:31AM (#29863026)
Yes, this is just part of life. Most open-source developers go well beyond the technically-correct "I don't owe you anything" stance and actively try to help their users, which includes adhering to SemVer, and trying to do more work so that the user doesn't have to.

However, you can't rely on this. Many open-source projects fill a niche and become popular when it isn't the intention of the author. This causes a disconnect where the users expect the project to be for them, when the project is really for the author. Mongoid seems to be more in the former category (for the user).

Because some libraries are badly managed, you need to audit all of them.

Re:A routine gem update ended up creating $73k worth of subs... by stouset on Saturday January 08, 2022 @02:12AM (#29849384)
This exact problem could have happened in any language. Literally zero of it has to do with Ruby or the ecosystem.
Re:A routine gem update ended up creating $73k worth of subs... by jchw on Saturday January 08, 2022 @03:08AM (#29849695)
Certainly it has something to do with the ecosystem, if the most popular MongoDB driver in the ecosystem is making breaking changes in minor versions.

That said, strong types can be a godsend for catching accidental breaks, even if it wouldn’t necessarily have helped here. A strongly typed language that has a more disciplined ecosystem is less likely to run into these kinds of issues.

It’s one of the tradeoffs you pick when deciding between languages. I decided the tradeoffs didn’t work well for me and left for compiled languages, for now.

Re:A routine gem update ended up creating $73k worth of subs... by julik on Saturday January 08, 2022 @05:07AM (#29850203)
This is exactly the case where nothing about types, language or opinions about the Ruby community has to do with the problem at hand.

This would not be caught by compiling, strong types or anything else - this is a change in behavior which has been arbitrarily done by the maintainers of the dependency.

> Certainly it has something to do with the ecosystem, if the most popular MongoDB driver in the ecosystem is making breaking changes in minor versions.

How should this be handled? Should a "good" ecosystem vet every single change in every single library that gets updated? Or should there be no libraries and only stdlib instead (wait, I think I know a compiled language which did just that for quite a few years, let me think which one that was again...)

Re:A routine gem update ended up creating $73k worth of subs... by jchw on Saturday January 08, 2022 @11:25AM (#29853138)
You can feel that it has nothing to do with the ecosystem or its norms, but it happened in the Ruby ecosystem right in a rather important foundational library, and anecdotally it does feel like it’s a problem that recurs over time. That doesn’t mean there’s a good solution. You can’t just upend the defacto attitude of an ecosystem at will.

> How should this be handled? Should a "good" ecosystem vet every single change in every single library that gets updated? Or should there be no libraries and only stdlib instead (wait, I think I know a compiled language which did just that for quite a few years, let me think which one that was again...)

This isn’t really about Ruby vs all compiled languages, I mean, Brainfuck is a compiled language and that doesn’t mean I was endorsing Brainfuck to replace Ruby. However I would certainly endorse Go to replace Ruby. Rust too, although using Rust to do web development stuff feels like using a nuclear warhead to open a door.

Anyway, the reason why types is relevant to this discussion is because types are contracts that are statically enforced and the break that occurred happened due to a contract change. This change illustrates that even if you do have types it doesn’t guarantee you won’t have breaking contract changes. However, eliminating entire classes of accidental or intentional contract breaks is an obvious win/win. If it was as complex and obtuse as C++, nobody would bother. But C++ isn’t the only game in town anymore for fast compiled strongly typed languages.

Re:A routine gem update ended up creating $73k worth of subs... by stouset on Saturday January 08, 2022 @02:22PM (#29855165)
> Certainly it has something to do with the ecosystem, if the most popular MongoDB driver in the ecosystem is making breaking changes in minor versions.

Am I to believe that you hold every other language to this same standard? A single maintainer of a reasonably popular project makes one boneheaded decision in a release, and that's enough reason to denounce the entire ecosystem?

> That said, strong types can be a godsend for catching accidental breaks...

Ruby is a strongly typed language.

You probably mean static types, but even that wouldn't have helped here. This was a behavioral change and did not affect any of the (implicit, in Ruby) type signatures of the function. It would not have affected any of the explicit type signatures of the function in other languages. I say this as an enormous proponent of Rust and static typing.

You are tilting at windmills.

Re:A routine gem update ended up creating $73k worth of subs... by jchw on Saturday January 08, 2022 @10:27PM (#29859682)
I am using the Wikipedia definition of 'strong' vs 'weak' typing.

> Generally, a strongly typed language has stricter typing rules at compile time, which implies that errors and exceptions are more likely to happen during compilation. Most of these rules affect variable assignment, function return values, procedure arguments and function calling. Dynamically typed languages (where type checking happens at run time) can also be strongly typed. Note that in dynamically typed languages, values have types, not variables.

Just out of curiosity, exactly what do you even think weakly typed could mean by your own definition of it?

No need to address the other points, because we're talking about anecdotes and not scientific data. Yes, I'm using a single data point as an example about a feeling I have to justify my opinion.

Re:A routine gem update ended up creating $73k worth of subs... by emodendroket on Saturday January 08, 2022 @02:49PM (#29855446)
But it's not really about a single maintainer and project, is it? The thing is that this sort of problem is somewhat common in this environment, which is why people have adopted "rules" they consider common sense about which hoops you're supposed to jump through before minor version updates.
Re:A routine gem update ended up creating $73k worth of subs... by astrowilson on Saturday January 08, 2022 @04:09AM (#29849960)
It definitely has something to do with Ruby and Rails. Ruby and Rails introduces API changes on minor versions all the time, sometimes even without prior warnings, so people shouldn’t expect related gems to be any different.
Re:A routine gem update ended up creating $73k worth of subs... by metafunctor on Saturday January 08, 2022 @03:41AM (#29849852)
You're right that the language isn't to blame as such.

But if a change like this doesn't cause some kind of uproar in the Ruby community, then the community has a problem.

Re:A routine gem update ended up creating $73k worth of subs... by astrowilson on Saturday January 08, 2022 @04:12AM (#29849972)
It won’t cause a uproar because Ruby/Rails changes APIs on minor versions all the time. Breaking changes are pushed at a yearly rate and everyone is just expected to cope with them.
Re:A routine gem update ended up creating $73k worth of subs... by metafunctor on Saturday January 08, 2022 @12:10PM (#29853637)
That’s what I’ve gathered. That still seems stupid to me. Why does the Ruby/Rails community do that?
Re:A routine gem update ended up creating $73k worth of subs... by ramchip on Saturday January 08, 2022 @04:38AM (#29850091)
In theory yes, but in practice there's a big difference between ecosystems. I maintain apps in Ruby and Elixir, and as far as I can remember, all the Elixir libraries I use respect semver. Whereas with Ruby it's much more mixed.
Re:A routine gem update ended up creating $73k worth of subs... by gedy on Saturday January 08, 2022 @02:47AM (#29849582)
No, this is particularly bad in Ruby. Many languages, esp. compiled do not have the same issues.
Re:A routine gem update ended up creating $73k worth of subs... by Gigachad on Saturday January 08, 2022 @03:24AM (#29849777)
That’s often the case but for this particular issue, it could have happened in any language because it’s still returning the exact same type. Its an array of the same record type in both instances.
Re:A routine gem update ended up creating $73k worth of subs... by emodendroket on Saturday January 08, 2022 @02:54PM (#29855484)
Ultimately this is more social than technical.
Re:A routine gem update ended up creating $73k worth of subs... by dagmx on Saturday January 08, 2022 @03:09AM (#29849706)
What language would avoid the problem?
Re:A routine gem update ended up creating $73k worth of subs... by chucke on Saturday January 08, 2022 @04:04AM (#29849945)
Java and log4j would like a word with you.
Re:A routine gem update ended up creating $73k worth of subs... by jorams on Saturday January 08, 2022 @07:28AM (#29851036)
The problem with log4j is that they didn't introduce a breaking change, allowing vulnerable functionality the maintainers already considered problematic to stick around.
Re:A routine gem update ended up creating $73k worth of subs... by joelbluminator on Saturday January 08, 2022 @02:02AM (#29849340)
This is quite rare and also types would have done nothing in this case.
Re:A routine gem update ended up creating $73k worth of subs... by gingerlime on Saturday January 08, 2022 @06:00AM (#29850512)
> Of course it’s easy to miss something, but unit tests could have caught this issue.

Nitpick, but I don't think unit tests would have caught this. Integration or systems tests might have caught this however, but those can be much harder to create and maintain in practice, in this particular case.

Re:A routine gem update ended up creating $73k worth of subs... by sorokod on Saturday January 08, 2022 @07:47AM (#29851173)
Well, you get what you pay for. If integration tests are viewed as too expensive, then an occasional penalty is just the price of doing business.
Re:A routine gem update ended up creating $73k worth of subs... by lordgroff on Friday January 07, 2022 @09:25PM (#29847952)
Yeah, semver is great, except nobody follows it. The amount of times I have updated minor or even patch releases of packages with things breaking--I have pretty much determined everything in a project stays the same unless there's some pressing need.

The worst part is that breakage is often far from obvious, and spending good time wondering why everything breaks when it shouldn't is really really infuriating and makes me feel like the entire world of software is hopelessly broken.

Re:A routine gem update ended up creating $73k worth of subs... by sofixa on Friday January 07, 2022 @10:59PM (#29848500)
> I have pretty much determined everything in a project stays the same unless there's some pressing need

Unless you have a way to stay up to date with the security of each and every dependency you have, that seems dangerous. There are static security scanners out there which can parse your dependency tree and alert you, but often they have a high noise ratio ( e.g. npm audit), so that only helps so much.

Re:A routine gem update ended up creating $73k worth of subs... by chousuke on Saturday January 08, 2022 @03:44AM (#29849874)
The "easy" way to do this is to write your application using whatever is included in a stable Linux distribution.

You get free, trivially applied security updates and a much lower chance of breakage. Optionally you can pay for support to have them fix problems in dependencies.

Granted, It'll be difficult with languages like Javascript where many popular dependencies aren't likely to be packaged.

Re:A routine gem update ended up creating $73k worth of subs... by lordgroff on Friday January 07, 2022 @11:53PM (#29848731)
Application is airgapped, so it's not as dangerous as it sounds.
Re:A routine gem update ended up creating $73k worth of subs... by tshaddox on Friday January 07, 2022 @10:28PM (#29848345)
When you say “breaking” in that comment are you talking about backwards compatible API changes, or straight up bugs? It kinda sounds like you’re talking about the latter, which of course isn’t within the scope of semver.
Re:A routine gem update ended up creating $73k worth of subs... by yebyen on Saturday January 08, 2022 @05:37AM (#29850369)
That's actually something that is in the author's purview to decide.

(Edit: whoops, I misread you. I thought you were saying APIs are not in scope for SemVer. Now I think I realized you meant, you can have bugs that break things and that's not related to semver.)

Is the semver contract with respect to the end user activities or the API? For Flux and Helm for example, the APIs are supported with semver code (and the interfaces use Kubernetes API versioning)

In Helm, the CLI and user activities are explicitly not part of the semver contract as I understand it, only the API (at least with respect to experimental features like OCI charts for now?)

Re:A routine gem update ended up creating $73k worth of subs... by lamontcg on Friday January 07, 2022 @09:34PM (#29848020)
A big part of the problem with SemVer is that "breaking changes" is subjective and there's always the xkcd spacebar heating problem.

The flip side of most breaking changes that are released is some software developer who either wasn't experienced enough to imagine that the change would break someone or else they're dealing with a very hard problem that they're trying to solve and the break change was collateral damage in some edge condition they didn't consider. Many people's breaking changes are someone else's bugfix, and often users fluidly wind up on either side of that condition on different bugs -- screaming about bugs that haven't been fixed for years and then screaming about other bugfixes that broke them.

Re:A routine gem update ended up creating $73k worth of subs... by lordgroff on Friday January 07, 2022 @11:59PM (#29848761)
Here's a recent example from sqlalchemy. I'm using a type annotation.

Update to new minor version. BAM, annotation no longer works, the classes have moved around and I'm staring at an ugly exception. To be clear: these were not private modules, methods, what have you. So we're not talking about the space bar issue here, it wasn't some undocumented or buggy behavior, things just stopped working as the API got shuffled around. At that point this was literally the third semver breakage in the same month, and yeah, this is unusual, but dependencies have stayed fixed since then, it's a headache and it makes me feel like everything is just built on a pile of shifting sand.

Re:A routine gem update ended up creating $73k worth of subs... by lamontcg on Saturday January 08, 2022 @05:26PM (#29857127)
That's probably because its open source and the Patreon contributions don't compare well to a FAANG staff SDE salary. SemVer is highly constraining and its a PITA to work with when you're getting a 6-figure salary.

TANSTAAFL.

Re:A routine gem update ended up creating $73k worth of subs... by Xavdidtheshadow on Saturday January 08, 2022 @06:04PM (#29857519)
> A big part of the problem with SemVer is that "breaking changes" is subjective

I don't think that's true. I've always thought a breaking change is defined in broad terms as "the public API surface, runtime, and output". Given that, each of these would be a SemVer major:

* remove a publicly-exported function * public function changes order of arguments * drop support for an old version of the language * a function changes behavior significantly (the issue the OP wrote about)

Relying on a specific major version, you should be able to assume none of the above will happen. The following would _not_ be a major version:

* renamed/removed private versions * add extra, optional arguments to public function * add support for new version of language * the xkcd example about CPU usage

In each of these cases, if you rely on non-guaranteed behavior, you should check every version upgrade closely- package maintainers don't make any assurances about those.

I'm not sure how mongoid is developed, but this smells like a bug to me. The `or` behavior started considering a thing it didn't used to, possibly unintentionally. Unfortunately, released mistakes are the one thing SemVer doesn't cover. Testing sufficiently about your own assumptions (in this case, that the user upgraded matches the one found in the query) is the best way to CYA.

Re:A routine gem update ended up creating $73k worth of subs... by lamontcg on Saturday January 08, 2022 @07:49PM (#29858503)
That is a nice neat and tidy way of thinking about changes. The messy details are things like "oh the default options result in a massive security hole, they need to change immediately". There's also a messy medium ground where behavior changes and its just a question as to if anyone is dependent upon that behavior. It was wrong when it was implemented, never documented, but has a currently defined behavior that most people don't want -- unless they happened to find it and use it and work around it and they'll be broken by the switch. This is the realm of things like the undefined behaviors of the C standard which are compiler-dependent. Any sufficiently complicated API will have those all over the place. You can argue that APIs should never have those kinds of undefined standards, but in reality everyone does shoddy work and people accept PRs that they shouldn't (and the flip side of trying to be careful is people yelling about open PRs that have been stalled for months/years trying to sort out a sufficiently robust solution).
Re:A routine gem update ended up creating $73k worth of subs... by Xavdidtheshadow on Sunday January 09, 2022 @02:48PM (#29866706)
> It was wrong when it was implemented, never documented, but has a currently defined behavior that most people don't want

That strikes me as exactly the sort of guarantee that's _not_ made by semver. You can rely on that behavior, but then you have to check against every patch version, because that's exactly the sort of thing that could change out from under you. Maintainers shouldn't worry about breaking this case- they never promised to support it in the first place.

I think a lot of those cases should be a major version change, and that's totally fine. We _should_ minimize the number of breaking changes to code people depend on, but sometimes the best fix to the (totally reasonable) situations you outlined above is to make a new major version. Users will have to make changes to upgrade (instead of just bumping the versions), but it won't change out from under them. Some docs about what's changing, why, and how to migrate your code go a long way here.

Re:A routine gem update ended up creating $73k worth of subs... by lamontcg on Sunday January 09, 2022 @08:46PM (#29869588)
We do major version bumps on a yearly cycle and people get stuck on 8 year old versions and won't upgrade. Its easy to say that integers are free and limitless, but constant major version upgrades are something that people won't tolerate one way or another either.

And you have to understand that the people making these decisions make dozens of them for every single release, and when they make category mistakes that is how you get breaking changes released early. Every single bug when looked at in isolation looks obvious what should have happened given hindsight bias.

And I just don't think open source software, that isn't corporate backed in one way or another, should ever go 1.0 and it should stay 0.x.y and go ahead and break compat every 3-6 months or so as necessary. The cost of SemVer and trying to get it continuously correct on every single patch is a large tax.

Re:A routine gem update ended up creating $73k worth of subs... by Xavdidtheshadow on Monday January 10, 2022 @03:12PM (#29881432)
> We do major version bumps on a yearly cycle and people get stuck on 8 year old versions and won't upgrade

We do the same thing and have the exact same experience, unfortunately. Software is a messy business and it's hard to apply strict rules to human process.

I think ultimately SemVer can be used to to accurately communicate if you, a user, are safe to upgrade between versions if applied strictly. Whether or not your users will (or be happy about it) is another ballgame.

Re:A routine gem update ended up creating $73k worth of subs... by BlackFingolfin on Friday January 07, 2022 @06:15PM (#29846308)
To be fair, the your second link points to the documentation of an ancient version; the new docs don't seem to mention semver (I still don't think what they are doing is reasonable, but ...)
Re:A routine gem update ended up creating $73k worth of subs... by ricardobeat on Friday January 07, 2022 @06:30PM (#29846452)
That link is reachable from their home page right now, under “Upgrading”.

EDIT: just noticed the docs I found via Google are marked as “old” in the URL: https://mongoid.github.io/old/en/mongoid/

Are you suggesting they dropped semver in between these releases?

Re:A routine gem update ended up creating $73k worth of subs... by rsynnott on Friday January 07, 2022 @07:31PM (#29847093)
> Are you suggesting they dropped semver in between these releases?

If this is the case, I kind of hope, for maximum irony, that they dropped it as part of a minor version bump.

Re:A routine gem update ended up creating $73k worth of subs... by neya on Saturday January 08, 2022 @04:35AM (#29850067)
Haha, this was the best thing I read today :)))
Re:A routine gem update ended up creating $73k worth of subs... by Railsify on Friday January 07, 2022 @07:01PM (#29846781)
Semantic Versioning does not mean you can update without reading the changelog. Blame here remains with the developer who updated without reading the changelog.
Re:A routine gem update ended up creating $73k worth of subs... by kortex on Friday January 07, 2022 @08:50PM (#29847710)
Do you or your team review every item of every changelog of every dependency in your stack (recursively for their dependencies) for every minor update, and/or 100% coverage for all of your assumptions of how they are used?

Sure it was a mistake by OP in TFA but it's an honest mistake any of us could make. And it's a really Bad Move by the Mongoid devs. It'd be a bad move in 1.2->1.3, but by 7.3? I'd just be like "whelp, this is how this function behaves now in perpetuity, I guess just document that it has different semantics than AR" even if an 8.0 was released. This is the kind of change which causes really subtle bugs. It's rarely worth it. Just introduce .chain_or() or something.

Re:A routine gem update ended up creating $73k worth of subs... by ljm on Saturday January 08, 2022 @05:53AM (#29850475)
I think you're trying to make the case sound a bit more absurd than it really is, in terms of recursively scanning dependencies and checking for 100% coverage for all assumptions.

It's really just as simple as going to the release notes and seeing if there's a mention of breaking changes or deprecations. If no such thing is mentioned then you're fine, otherwise you go and see if that change affects you at all and just take a little bit more time to test the upgrade. This has been standard practice at plenty of places that I've worked.

It also doesn't mean that it makes the change a particularly good one, but I don't think I can make a bunch of OSS maintainers responsible for my own failure to review an upgrade and test it before rolling it out. In those terms, there is some culpability both with the maintainers and with the library users.

Re:A routine gem update ended up creating $73k worth of subs... by Railsify on Saturday January 08, 2022 @01:29PM (#29854574)
This is well stated. It's about taking your fair share of responsibility, as engineering we bend code to our will, this includes reading the code of opensource packages.
Re:A routine gem update ended up creating $73k worth of subs... by Railsify on Saturday January 08, 2022 @01:26PM (#29854551)
Yes, I generally scan the changelog and look at the diff on github from the previous version. Not doing so is penny wise and pound foolish, the risk to brand and the risk of downtime is too great to install a crypto miner, or a vulnerable log4j version, etc.
Re:A routine gem update ended up creating $73k worth of subs... by kinduff on Friday January 07, 2022 @07:55PM (#29847314)
Learned this the hard way. No matter the change or version, I always try to double check both CHANGELOG and the commits.
Re:A routine gem update ended up creating $73k worth of subs... by montblanc on Friday January 07, 2022 @09:54PM (#29848142)
I think tests should have caught that one but I agree.
Re:A routine gem update ended up creating $73k worth of subs... by henry700 on Friday January 07, 2022 @10:04PM (#29848202)
Not if you follow the One True Way of Unit Testing (tm) where the Mongoid lib would have been mocked away, and the test would pass :)

Integration tests might've done the job here.

Re:A routine gem update ended up creating $73k worth of subs... by montblanc on Saturday January 08, 2022 @03:27AM (#29849787)
You dont mock the db layer, i dont do that at least, hell no. Let the db be hit, check that the records it returns make sense. Thats how I roll at least.
Re:A routine gem update ended up creating $73k worth of subs... by henry700 on Sunday January 09, 2022 @11:08PM (#29870521)
Didn't want to aim at you with the reply, just remembered the collective delusion of 100% coverage unit testing zealots and how this would ironically fail to catch this.

You'd be surprised how far people go to shoot themselves in the foot.