The only case where I have seen this happen is, when there is a bug somewhere and you should never gracefully handle it, but throw an exception.
Most probably it will just be absent on a clean build but there on an incremental build, which just makes it worse as you then transform always a stale artifact (the one from last build) and that result will be used further on.
These bugs can be in plugins, build scripts, or also in Gradle itself like these:
https://github.com/gradle/gradle/issues/29847
https://github.com/gradle/gradle/issues/27372
Unfortunately, there is still no protection against prematurely evaluated artifact transforms. With
https://github.com/gradle/gradle/issues/11100 hopefully something is coming. I was told they leave look at it this year, but we'll see.