Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear error messages in Mockative KSP processor #97

Closed
vitorhugods opened this issue Apr 16, 2024 · 1 comment · Fixed by #103
Closed

Unclear error messages in Mockative KSP processor #97

vitorhugods opened this issue Apr 16, 2024 · 1 comment · Fixed by #103

Comments

@vitorhugods
Copy link
Contributor

vitorhugods commented Apr 16, 2024

Starting on Mockative 2.2.0, I'm facing this issue when running kspDebugAndroidTestKotlinAndroid (here's the codebase I'm running it on).

> Task :logic:kspDebugAndroidTestKotlinAndroid FAILED
e: [ksp] java.lang.IllegalStateException: Required value was null.
	at com.squareup.kotlinpoet.ksp.UtilsKt.toClassNameInternal(utils.kt:63)
	at com.squareup.kotlinpoet.ksp.KsClassDeclarationsKt.toClassName(KsClassDeclarations.kt:23)
	at io.mockative.ProcessableType$Companion.fromDeclaration(ProcessableType.kt:82)
	at io.mockative.ProcessableType$Companion.fromResolver(ProcessableType.kt:143)
	at io.mockative.MockativeSymbolProcessor.process(MockativeSymbolProcessor.kt:25)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:310)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:308)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:414)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:308)

I am trying to get more information about it. I'm not sure what is the edge case I'm falling into at the moment, as it doesn't seem to have affected Mockative's :shared:kspDebugAndroidTestKotlinAndroid for example.


Findings

I copied mockative-processor into the project and ran it from local source + attached a debugger to it.

I see some class is KSErrorTypeClassDeclaration when calling fromDeclaration:

grafik

After more debugging, I found out:

grafik

I was solving conflicts during the Mockative 2.x upgrade and had a missing import in an Android-specific test.

There was no message that could lead me to the correct place and I really had to attach a debugger to check it out.


TL;DR:

We could improve error handling and provide more helpful error messages during KSP compiling. Maybe just spitting out a Failure during processing of property 'propertyName' in file 'path/to'file' would be helpful enough.

@vitorhugods vitorhugods changed the title Failure to get class name during code generation on some Android source sets Unclear error messages in Mockative KSP processor Apr 16, 2024
@Nillerr
Copy link
Collaborator

Nillerr commented Apr 17, 2024

Good catch, and thank you for debugging the issue @vitorhugods! I will add a nice error for these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants