Skip to content

database analyze failing for Swift #18678

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

Closed
JamesW-iOS opened this issue Feb 4, 2025 · 2 comments · Fixed by #18684
Closed

database analyze failing for Swift #18678

JamesW-iOS opened this issue Feb 4, 2025 · 2 comments · Fixed by #18684
Labels
question Further information is requested

Comments

@JamesW-iOS
Copy link

Description of the issue

I seem to be having an issue running codeQL database analyze it's failing to run with an Internal error. I am able to build the database successfully but running the analyze produces several errors. Not sure if this is expected behavior, a configuration error on my end, or an issue in the tool(perhaps related to this issue) Would really appreciate any help, please let me know if there are any other logs or debug steps that would be helpful.

Environment
Swift 6 compiler running in v5 language mode for the main app target and all packages
Xcode 16.1

Building database

Command
codeql database create ./dbs/myApp --language=swift --source-root ./myApp --overwrite --command="./make.sh"

Final output
Successfully created database at /Users/jameswarren/dbs/myApp

make.sh

#!/bin/sh
xcodebuild build -workspace ./myApp.xcworkspace -scheme myApp-Prod -skipPackagePluginValidation -configuration Debug -destination "generic/platform=iOS Simulator"

This seems to work as expected up to this point

analyze

codeql database analyze ./dbs/myApp --format csv --output ./results/myApp.csv

This then fails with the following error

Shutting down query evaluator.
Interpreting results.
CodeQL scanned 1980 out of 2765 Swift files in this invocation. Typically CodeQL is configured to analyze a single CodeQL language per invocation, so check other invocations to determine overall coverage information.
Analysis produced the following diagnostic information:
  - Internal error (49 results):
    * CodeQL encountered an unexpected internal error with the following message:
    > Assertion failed: `keyPathType`. KeyPathExpr must have BoundGenericClassType

    Some or all of the Swift analysis may have failed.

    If the error persists, contact support, quoting the error message and describing what happened, or [open an issue in our open source repository][1].

    [1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md
    * CodeQL encountered an unexpected internal error with the following message:
    > Assertion failed: `keyPathType`. KeyPathExpr must have BoundGenericClassType

    Some or all of the Swift analysis may have failed.

    If the error persists, contact support, quoting the error message and describing what happened, or [open an issue in our open source repository][1].

    [1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md
    * CodeQL encountered an unexpected internal error with the following message:
    > Assertion failed: `keyPathType`. KeyPathExpr must have BoundGenericClassType

    Some or all of the Swift analysis may have failed.

    If the error persists, contact support, quoting the error message and describing what happened, or [open an issue in our open source repository][1].

    [1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md
    * CodeQL encountered an unexpected internal error with the following message:
    > Assertion failed: `keyPathType`. KeyPathExpr must have BoundGenericClassType

    Some or all of the Swift analysis may have failed.

    If the error persists, contact support, quoting the error message and describing what happened, or [open an issue in our open source repository][1].

    [1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md
This query also produced a further 44 messages that are omitted here.

Analysis produced the following metric data:

|             Metric             | Value |
+--------------------------------+-------+
| Number of unresolved AST nodes |    78 |
@JamesW-iOS JamesW-iOS added the question Further information is requested label Feb 4, 2025
@redsun82
Copy link
Contributor

redsun82 commented Feb 5, 2025

👋 @JamesW-iOS Thanks for reporting this! That internal error is indeed a bug, that should be fixed in the next release.

That said, did the analyse command really fail with an exit code, or did it just print out those errors but returned with a successful exit code and produce the ./results/myApp.csv output? As far as I can tell, those errors shouldn't be fatal, although it may imply missing some results.

@redsun82
Copy link
Contributor

redsun82 commented Feb 5, 2025

@JamesW-iOS I've pushed a fix for the error message you experienced. This will take around a couple of weeks before being released.

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

Successfully merging a pull request may close this issue.

2 participants