Kotlin / kotlinx-kover

Apache License 2.0
1.27k stars 47 forks source link

[0.7.4] Cannot access input property `externalReports$kover_gradle_plugin` of task #478

Closed wezley98 closed 6 months ago

wezley98 commented 7 months ago

Describe the bug Upgrade from 0.7.3 -> 0.7.4 (0.7.3 works as expected with no errors)

Errors Cannot access input property 'externalReports$kover_gradle_plugin' of task ':kover:koverHtmlReportDebug'. Accessing unreadable inputs or outputs is not supported. Declare the task as untracked by using Task.doNotTrackState(). For more information, please refer to https://docs.gradle.org/8.4/userguide/incremental_build.html#disable-state-tracking in the Gradle documentation.

Expected behavior Build passes with no errors

Environment

shanshin commented 7 months ago

Hi, It seems that this problem is not directly related to the version of Kover, because it has already been encountered before.

It is not possible to reproduce this problem locally, so a small project producer would really help us (if anyone encounters this error on a small open source project).

guerrerorodrigo commented 7 months ago

@shanshin we have the same issue. It appeared only when bumping to version 0.7.4. Nothing else changed, just the version.

HarisHoulis commented 7 months ago

We have the same exact issue.

Also, we noticed that Release 0.7.4 CI build fails here which seems it could be related to the suggestion Gradle prints (Incremental builds & Gradle cache)

shanshin commented 7 months ago

Also, we noticed that Release 0.7.4 CI build fails here which seems it could be related to the suggestion Gradle prints (Incremental builds & Gradle cache)

There are a lot of tests on the build cache, but only this one fell (it was unstable before), besides, it fell before using the cache. It is unlikely that it is related to the current problem.

shanshin commented 7 months ago

@guerrerorodrigo, is it reproduced only on CI or also locally? Is there a more detailed error ? For example like

> Cannot access input property 'externalSources$kover_gradle_plugin' of task ':app:koverXmlReportBetaPreProdDebug'. Accessing unreadable inputs or outputs is not supported. Declare the task as untracked by using Task.doNotTrackState(). See https://docs.gradle.org/8.1.1/userguide/incremental_build.html#disable-state-tracking for more details.
   > Failed to create MD5 hash for file '/usr/bin/sudo' as it does not exist.

in https://github.com/Kotlin/kotlinx-kover/issues/391#issuecomment-1612723009

HarisHoulis commented 7 months ago

@shanshin Weirdly it fails both locally. (reproduced across multiple machines) and on our CI but with different errors:

CI:

Cannot access input property 'externalReports$kover_gradle_plugin' of task ':app:koverXmlReportDebug'. Accessing unreadable inputs or outputs is not supported. Declare the task as untracked by using Task.doNotTrackState(). For more information, please refer to https://docs.gradle.org/8.4/userguide/incremental_build.html#disable-state-tracking in the Gradle documentation.

...
(stacktrace)
...

Could not stat file /__w/myProject/��9|���_��\fY\x03�g\c?*#�\v\x1E�S�ݒ`7�IE��\x0F��\f'��T�`F1��5�$�E��o5.>|\eߑ�-|��n�狘�i\x1E/***�\x1C���G���\x05��j*$/!�c~�I�5�\c?<�\a��8C��\x1A��v�HSc����Wr�pH+K��O?b�\x17(�ǹ��H�.�c��R��YY򳘣�\x11w��\x1D�\x15h�;w�\x03>\x0F\vx\x02���we����u�|��_***�v��������\x13��z��,�***�䞒�\x0F***���H�***����ttx\x05�1\a�<�W��p\a�9�)�***�***��\x15���j�yc***ۜ��+�sh�\x16Ӿz\f\x1C$\x1E�\x10q�\x19s�"Y\c?�&�y�.�\x1D:k��J\x115[��d�*c�I�

...
(stacktrace)
...

net.rubygrapefruit.platform.NativeException: Could not get file details of /__w/myproject/��9|���_��\fY\x03�g\c?*#�\v\x1E�S�ݒ`7�IE��\x0F��\f'��T�`F1��5�$�E��o5.>|\eߑ�-|��n�狘�i\x1E/***�\x1C���G���\x05��j*$/!�c~�I�5�\c?<�\a��8C��\x1A��v�HSc����Wr�pH+K��O?b�\x17(�ǹ��H�.�c��R��YY򳘣�\x11w��\x1D�\x15h�;w�\x03>\x0F\vx\x02���we����u�|��_***�v��������\x13��z��,�***�䞒�\x0F***���H�***����ttx\x05�1\a�<�W��p\a�9�)�***�***��\x15���j�yc***ۜ��+�sh�\x16Ӿz\f\x1C$\x1E�\x10q�\x19s�"Y\c?�&�y�.�\x1D:k��J\x115[��d�*c�I�: could not convert string to current locale

ℹ️ (the file path is exactly how it's being printed on our CI logs)

Locally:

Execution failed for task ':app:koverHtmlReportDebug'
Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it

🤷🏻

shanshin commented 7 months ago

@HarisHoulis, if I publish a special version with advanced logging, could you run this version locally to test multiple versions?

There is an assumption that random files fall into the list of Kover artifacts, which Kover tries to read as a text file and parse file names from there.

HarisHoulis commented 7 months ago

@shanshin I will try to reproduce it in an open-source demo project and share it with you.

In the meantime, @wezley98 will @shanshin's proposal be of interest in your affected project?

sureshg commented 7 months ago

@shanshin got the same error when upgrading from 0.7.3 to 0.7.4. The thing is CI build is failing only for windows - https://github.com/sureshg/openjdk-playground/actions/runs/6488852919/job/17622062272#step:8:1352 . Linux and mac builds are working as expected.

* What went wrong:
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
Execution failed for task ':koverHtmlReport'.

> Cannot access input property 'externalReports$kover_gradle_plugin' of task ':koverHtmlReport'. Accessing unreadable inputs or outputs is not supported. Declare the task as untracked by using Task.doNotTrackState(). For more information, please refer to https://docs.gradle.org/8.4/userguide/incremental_build.html#disable-state-tracking in the Gradle documentation.
shanshin commented 7 months ago

@HarisHoulis, @wezley98 , @sureshg
It looks like this is a problem with the relative paths used after the #440 fix. In this case, it would help to look at the contents of the build/kover/*.artifact files from the root project and the subprojects it depends on.

HarisHoulis commented 7 months ago

@shanshin I will look into a way to pull those artifacts from our CI, since we can't run Kover locally.

HarisHoulis commented 7 months ago

@shanshin Can you please provide me a secure way to share our **/build/kover/*.artifact files with you?

shanshin commented 7 months ago

@HarisHoulis, by e-mail sergey.shanshin@jetbrains.com

You may also replace all sensitive names: so that the same substituted name corresponds to the same source directory name.

DevNatan commented 7 months ago

@shanshin Exactly same issue but with 0.7.3 and only happens when using kover for "Single report over several projects". All reports works but modules with kover(...) in dependencies block are broken. Kover v0.7.3, Gradle v8.4.

On CI fails with (ubuntu-22.04)

java.io.IOException: Cannot snapshot /dev/core: not a regular file

Locally fails with (macOS Sonoma)

Failed to create MD5 hash for file '/usr/bin/sudo' as it does not exist.

Tried to bump kover to 0.7.4. Same error on CI. Now local fails with

Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it
shanshin commented 7 months ago

@HarisHoulis, thanks for the files! Unfortunately, there is nothing unusual in the contents of this file.

@sureshg, thanks for the project! I will try to reproduce locally if the problem still repeats!

bmarty commented 6 months ago

Hello,

I have also the issue with Kover 0.7.4, both locally and on the CI.

* What went wrong:
Execution failed for task ':app:koverHtmlReportRelease'.
> Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it

The project is open source, here is the PR: https://github.com/vector-im/element-x-android/pull/1782

And the CI build https://github.com/vector-im/element-x-android/actions/runs/6815987723/job/18536289873?pr=1782

If I use Kover 0.7.3, this error is not observed (but I have other issue I am working on right now).

r4phab commented 6 months ago

Hello,

I have also the issue with Kover 0.7.4, both locally and on the CI.

* What went wrong:
Execution failed for task ':app:koverHtmlReportRelease'.
> Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it

The project is open source, here is the PR: https://github.com/vector-im/element-x-android/pull/1782

And the CI build https://github.com/vector-im/element-x-android/actions/runs/6815987723/job/18536289873?pr=1782

If I use Kover 0.7.3, this error is not observed (but I have other issue I am working on right now).

Exactly the same error on my side and it is raised only with a mix of JVM and Android reports with the mergedWith property. If I run Kover with only JVM or only Android reports, everything works fine ..

shanshin commented 6 months ago

@bmarty, thanks for the reproducer! It stably reproduces the error locally

shanshin commented 6 months ago

Finally, I think I've found the reason.

The reason is that in some cases, when there is a merge of subprojects in which there are no overlapping variants (e.g. default variant, and Android build variant), a this error appears. For example, in project https://github.com/vector-im/element-x-android/pull/1782, project appconfig is added to the merged report :app:koverHtmlReportRelease, this error happens, because variant release is missing in JVM-only subprojects.

Unfortunately, so far I have not found a completely correct solution using Gradle, and I have created related Gradle issue: https://github.com/gradle/gradle/issues/27019

I'll try to get rid of the fall by workarounds, however, the primary issue is in the configuration of the build. When mixed types of Kotlin projects (Android + JVM) are used in the build at the same time, it is better to use koverHtmlReport task, and merging variants in Android subprojects:

koverReport {
    defaults {
        // adds the contents of the reports of `release` Android build variant to default reports
        mergeWith("release")
    }
}

also in docs

shanshin commented 6 months ago

Fixed in 0.7.5

Now, in case of an incorrect Kover configuration, a more meaningful message is thrown out.