{"record":{"id":"631180de559e28d8","repo":"aaif-goose/goose","slug":"could-not-find-findlibraryname-in-generated-kotlin","errorCode":null,"errorMessage":"could not find findLibraryName in generated Kotlin bindings","messagePattern":"could not find findLibraryName in generated Kotlin bindings","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"crates/goose-sdk/scripts/prepare-maven-package.sh","lineNumber":52,"sourceCode":"cp LICENSE \"$resources_dir/META-INF/LICENSE\"\n\n\"$bindgen\" generate \\\n  --library \"$native_lib\" \\\n  --config crates/goose-sdk/uniffi.toml \\\n  --language kotlin \\\n  --no-format \\\n  --out-dir \"$kotlin_dir\" 2>/dev/null\n\npython3 - \"$kotlin_dir/io/github/aaif_goose/goose.kt\" <<'PY'\nimport sys\nfrom pathlib import Path\n\npath = Path(sys.argv[1])\ntext = path.read_text()\nneedle = 'private fun findLibraryName(componentName: String): String {\\n'\nreplacement = needle + '    NativeLibraryLoader.ensureLoaded()\\n'\nif needle not in text:\n    raise SystemExit('could not find findLibraryName in generated Kotlin bindings')\npath.write_text(text.replace(needle, replacement, 1))\nPY\n\ncp -R \"$support_kotlin_dir\"/. \"$kotlin_dir\"/\ncp \"$native_lib\" \"$resources_dir/$resource_prefix/\"\n","sourceCodeStart":34,"sourceCodeEnd":58,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-sdk/scripts/prepare-maven-package.sh#L34-L58","documentation":"SystemExit raised by the Python patch step in crates/goose-sdk/scripts/prepare-maven-package.sh when the generated Kotlin bindings file (goose.kt from uniffi-bindgen) does not contain the exact line 'private fun findLibraryName(componentName: String): String {'. The script injects NativeLibraryLoader.ensureLoaded() right after that line; if the generator's output format drifted, the anchor is gone and patching aborts.","triggerScenarios":"Running prepare-maven-package.sh after a uniffi-bindgen or uniffi macro upgrade that renames findLibraryName, changes its signature/formatting, or reorders the generated code; also when the .kt file is generated into a different path and the target file is stale or empty.","commonSituations":"Cargo/UniFFI version bump in CI changes generated-code formatting; the out-dir layout of uniffi-bindgen changed (package path io/github/aaif_goose moved); regeneration failed upstream (exit hidden by 2>/dev/null) leaving an old or empty goose.kt.","solutions":["Open $kotlin_dir/io/github/aaif_goose/goose.kt and locate the library-loading function; note its current exact signature/text","Pin the uniffi-bindgen / uniffi crate versions to the pair that produced the expected layout","Update the needle string in prepare-maven-page.sh's Python step to match the newly generated line","Check that the uniffi-bindgen invocation above the patch step actually succeeded (remove 2>/dev/null to see errors) before patching"],"exampleFix":"# before (script)\nneedle = 'private fun findLibraryName(componentName: String): String {\\n'\n\n# after — match current generated output, e.g.\nneedle = 'private fun findLibraryName(componentName: String): String {\\n'  # keep in sync with uniffi-bindgen output; pin its version instead when possible","handlingStrategy":"validation","validationCode":"kt=\"$kotlin_dir/io/github/aaif_goose/goose.kt\"\ngrep -q 'private fun findLibraryName(componentName: String): String {' \"$kt\" || { echo \"generated bindings drifted; pin uniffi versions\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin uniffi and uniffi-bindgen versions in Cargo/requirements","Fail the script loudly when the anchor line is missing (already does) and treat it as a version-drift signal","Add a CI smoke test that runs prepare-maven-package.sh on every dependency bump"],"tags":["uniffi","kotlin","bindings","release","ci"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}