apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Workflow fails in legacy prompt format: “Cannot use ‘in’ operator to search for ‘choices’ in OK”

Open joeMba opened this issue 1 month ago • 26 comments

Summary

Description:

The workflow fails during simple inference without tools (legacy prompt format). The API call returns the string OK instead of a JSON completion object, and the response handler then throws a TypeError.

Logs:

Using legacy prompt format Running simple inference without tools Error: API error: TypeError: Cannot use 'in' operator to search for 'choices' in OK

Suspected cause(to be confirmed during fixing): Wrong endpoint/base URL, or a non-JSON response reaching a code path that assumes an object. The handler should check typeof response === 'object' before using in.

Steps to reproduce

  1. Open a PR
  2. Upon workflows running
  3. Check Pull Request Scope / check-scope (pull_request) fails

Expected behaviour

Either a valid completion response, or a clear error explaining that the API returned an unexpected response (including status code and body).

Actual behaviour

An unhandled TypeError from 'choices' in response where response is the string "OK".

Device name

Workflows(Github)

Android version

Workflows(Github)

Commons app version

Workflows(Github)

Device logs

Shown in the screenshot below

Screenshots

Image

Would you like to work on the issue?

Yes

joeMba avatar Oct 20 '26 19:10 joeMba

Even if we fix the workflow, we need to check for a GitHub models alternative that have been deprecated.

RitikaPahwa4444 avatar Oct 20 '26 20:10 RitikaPahwa4444

Agreed, that makes sense. A deprecated model could also be the root cause of the OK response, so I’ll check that first.

joeMba avatar Oct 20 '26 20:10 joeMba

Hello @RitikaPahwa4444, @nicolas-raoul

To clarify the scope: this failure does not appear to come from this repository's code.

  • The check-scope workflow passes the PR content to actions/ai-inference@v1 and consumes its result. The workflow itself does not parse the API response, and a search of the repository for the error-related terms (choices, legacy prompt, simple inference) finds nothing.
  • The same failure occurs on another PR with different content, which indicates that this is not specific to the changes or prompt content of a particular contributor's PR.
  • The workflow does not provide an endpoint override, so the action is using the GitHub Models inference endpoint. GitHub retired GitHub Models and its inference API on July 30, 2026 retirement, and the run history shows the failures becoming sustained around that time.

I can't prove exactly what returned the OK (the retired endpoint or an intermediary), because the workflow log does not expose the HTTP status or response headers. The retirement is therefore the most likely trigger, rather than a confirmed root cause.

So fixing the workflow's error handling alone won't make the check work again. As @RitikaPahwa4444 mentioned, it also needs an alternative to GitHub Models. I'd suggest making the step non-blocking as a temporary measure, and then evaluating supported replacements. Any thoughts?

joeMba avatar Oct 21 '26 14:10 joeMba

It's non-blocking only, we're reviewing and merging the PRs.

GitHub had suggested some alternative as far as I remember, so we can check whether that's free and could be replaced directly.

RitikaPahwa4444 avatar Oct 21 '26 15:10 RitikaPahwa4444

If a free replacement is not available quickly, how about disabling this check for now? It makes real problems less visible.

nicolas-raoul avatar Oct 22 '26 10:10 nicolas-raoul

I do agree with you @nicolas-raoul!, but of course, as we get a solution.

joeMba avatar Oct 22 '26 10:10 joeMba

Hello @RitikaPahwa4444 @nicolas-raoul,

I looked into the alternatives, and I think GitHub Copilot CLI is the most natural option to investigate first.

The current actions/ai-inference@v1 action supports Copilot as its provider, using the GitHub Copilot CLI. This means we may be able to keep the existing actions/ai-inference approach without rewriting the check-scope workflow from scratch.

The main thing to confirm would be whether the project has access to a suitable Copilot plan/token for use in GitHub Actions and whether the maintainers are comfortable making Copilot a CI dependency.

Other alternatives we could think of include the following;

Microsoft Foundry — GitHub's recommended direction for direct model access after GitHub Models' retirement, with access to multiple models.

OpenAI API — straightforward to integrate, but would require a separate API key and potentially paid usage.

Hugging Face — could provide access to open models, but would introduce another external dependency and would need us to check the available free limits. Thanks!

joeMba avatar Oct 22 '26 11:10 joeMba

Please try in your forked repository, and when you find a solution, send a pull request here. Thanks! :-)

nicolas-raoul avatar Oct 22 '26 13:10 nicolas-raoul

Hello @nicolas-raoul , I have some nice updates right here . Though it is still a WIP but there is progress!

joeMba avatar Oct 26 '26 13:10 joeMba

I am trying to push PRs on the fork n see how the workflows behave. So far so good!

joeMba avatar Oct 26 '26 13:10 joeMba

Nice!

nicolas-raoul avatar Oct 26 '26 13:10 nicolas-raoul

Hello @nicolas-raoul , here is a well polished fix! Your review is highly appreciated. Thanks!

joeMba avatar Oct 27 '26 20:10 joeMba

I ended up switching to OpenRouter because Gemini no longer offered a suitable free-tier option. I've also configured the required secret and repository variable on my fork for testing. Thanks! CC @nicolas-raoul @RitikaPahwa4444

joeMba avatar Oct 27 '26 20:10 joeMba

What are the conditions for the OpenRouter free tier? For instance, do we have to pay if consumption is higher than expected? Thanks!

nicolas-raoul avatar Oct 28 '26 03:10 nicolas-raoul

Not really!. When we go past the limit(50 requests/day) as reported right here, requests fail until it resets. There's this code snippet if [[ "$model" != *:free ]]; then echo "::error::OpenRouter model ID must end in :free." exit 1 fi
if for instance someone "accidentally" changed the model to a paid OpenRouter model, the workflow fails instead of making a paid request. One gigantic caveat we have though is reliability(free models OpenRouter inclusive can be discontinued any time)

joeMba avatar Oct 28 '26 05:10 joeMba

Sounds good to me. :-)

@RitikaPahwa4444 Do you want to use your account? If you'd rather not, I can try creating an account.

nicolas-raoul avatar Oct 28 '26 12:10 nicolas-raoul

Sure, I can add mine.

RitikaPahwa4444 avatar Oct 28 '26 12:10 RitikaPahwa4444

Reopening as this doesn't run on forks

RitikaPahwa4444 avatar Nov 01 '26 09:11 RitikaPahwa4444

Hello @RitikaPahwa4444! is it fine if we close this issue as well?

joeMba avatar Nov 01 '26 09:11 joeMba

23. Reopening as this doesn't run on forks

sorry for the late reply @RitikaPahwa4444, is it now resolved?

joeMba avatar Nov 01 '26 09:11 joeMba