Graceful first-PR config fallback #22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When a pull request introduces
.forgejo/ai-review.ymlitself (the first PR that adds the review configuration to a repository), the review workflow fails withprovider.model or OLLAMA_MODEL is requiredbecause the action reads the configuration from the base commit (the trusted revision), and the base commit does not yet contain the file.This is a chicken-and-egg problem: the very first PR that adds the review setup cannot itself be reviewed by it.
Reproduction
.forgejo/ai-review.yml..forgejo/workflows/ai-review.yml) and a new.forgejo/ai-review.ymldescribing the provider.reviewjob fails immediately with:reviewer.pyconfirms the cause:fetch_config()returns{}on 404 (the base commit does not have the file yet), andprovider_request()then raisesValueError("provider.model or OLLAMA_MODEL is required")becauseprovider.get("model", os.environ.get("OLLAMA_MODEL"))finds neither.Suggested behavior
The action should degrade gracefully when the trusted-base config is missing, instead of hard-failing:
fetch_config()returns{}(or throws a non-404 error), log a clear diagnostic rather than letting the missingprovider.modelraise later.OLLAMA_MODELandOLLAMA_BASE_URLare already consulted as fallbacks inprovider_request(); the same fallback chain should also apply when the config object is empty so a degraded review (noanalysis.commands, default review settings) can still run.analysis.commandsis missing, therun_checks()loop simply iterates over nothing — that already works. The reviewer should mention in the rendered comment that deterministic checks were not configured.Workaround (for context)
Until this is fixed, consumers can hard-code the fallback in the workflow step that calls the action:
The reviewer already reads these as fallbacks, so this gives a degraded review on the bootstrap PR. But pushing the model/endpoint URL into two places (config file and workflow env) is brittle and duplicates a value that should live in one place.
Environment
forgejo-auto-pr-reviewrevision: currentmain(commit1d35f73at time of writing).forgejo/ai-review.ymlnova.mesh:11434, modelqwen3.6:35b-a3b-q8_0Happy to send a PR against this repo once we agree on the desired behavior.