From 781df2188cd301f85017ddf940cc00694a087233 Mon Sep 17 00:00:00 2001 From: ChethanUK Date: Tue, 21 Jul 2026 15:49:21 +0200 Subject: [PATCH] docs(examples): OCR_LLM_MODEL is required, not optional The GitLab example documented OCR_LLM_MODEL as optional with a gpt-4o default in three places. There is no such default: internal/llm/resolver.go:411 treats an empty model as unresolved, and the only gpt-4o in non-test Go code is a provider catalogue entry at internal/llm/providers.go:292. Unset, the variable word-splits away and leaves a 2-arg 'ocr config set', so parseConfigArgs sees ["set", "llm.model"] and the len(args) < 3 guard at cmd/opencodereview/flags.go:268 rejects it with the opaque usage error returned on :269. Add ${VAR:?} guards naming each missing variable, quote all three assignments, correct the docs in both READMEs, and drop the dead 'mkdir -p ~/.open-code-review' - the real config dir is ~/.opencodereview. --- examples/gitflic_ci/README.md | 2 +- examples/gitlab_ci/.gitlab-ci.yml | 13 ++++++++----- examples/gitlab_ci/README.md | 12 +++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/gitflic_ci/README.md b/examples/gitflic_ci/README.md index 9f36ce73..3d052b45 100644 --- a/examples/gitflic_ci/README.md +++ b/examples/gitflic_ci/README.md @@ -39,7 +39,7 @@ Go to **Settings → CI/CD → Variables** and add: | `OCR_LLM_URL` | Yes | LLM API endpoint URL | | `OCR_LLM_AUTH_TOKEN` | Yes | LLM API authentication token | | `GITFLIC_TOKEN` | Yes | GitFlic access token used to post discussions | -| `OCR_LLM_MODEL` | No | Model name (e.g., `gpt-4o`) | +| `OCR_LLM_MODEL` | Yes | Model name (e.g., `gpt-4o`) — OCR has no built-in default model and fails when this is unset | | `GITFLIC_API_URL` | No | REST API base URL for self-hosted GitFlic (default: `https://api.gitflic.ru`) | > **Note:** GitFlic CI/CD does not accept variables with values shorter than 8 characters, so `use_anthropic` cannot be set as a CI variable. The pipeline sets it to `false`; to use Anthropic Claude models, edit `gitflic-ci.yaml` directly. diff --git a/examples/gitlab_ci/.gitlab-ci.yml b/examples/gitlab_ci/.gitlab-ci.yml index e8c3f784..9b9d6f81 100644 --- a/examples/gitlab_ci/.gitlab-ci.yml +++ b/examples/gitlab_ci/.gitlab-ci.yml @@ -7,9 +7,10 @@ # Required CI/CD Variables (Settings → CI/CD → Variables): # OCR_LLM_URL - LLM API endpoint (e.g., https://api.openai.com/v1/chat/completions) # OCR_LLM_AUTH_TOKEN - Authentication token for the LLM API (mark as "Masked") +# OCR_LLM_MODEL - Model name (e.g., gpt-4o). OCR has no built-in default model; the +# pipeline fails fast if this is unset. # # Optional CI/CD Variables: -# OCR_LLM_MODEL - Model name (default: gpt-4o) # GITLAB_API_TOKEN - GitLab Personal/Project Access Token with "api" scope # (falls back to CI_JOB_TOKEN if not set) # @@ -48,12 +49,14 @@ code-review: - echo "OpenCodeReview installed with version:" && ocr version || true # Configure OCR - - mkdir -p ~/.open-code-review # Gitlab CI/CD does not support configuring variables with value length less than 8, so you can't set use_anthropic as a CI variable - | - ocr config set llm.url $OCR_LLM_URL - ocr config set llm.auth_token $OCR_LLM_AUTH_TOKEN - ocr config set llm.model $OCR_LLM_MODEL + : "${OCR_LLM_URL:?set OCR_LLM_URL in Settings -> CI/CD -> Variables}" + : "${OCR_LLM_AUTH_TOKEN:?set OCR_LLM_AUTH_TOKEN in Settings -> CI/CD -> Variables}" + : "${OCR_LLM_MODEL:?set OCR_LLM_MODEL in Settings -> CI/CD -> Variables}" + ocr config set llm.url "$OCR_LLM_URL" + ocr config set llm.auth_token "$OCR_LLM_AUTH_TOKEN" + ocr config set llm.model "$OCR_LLM_MODEL" ocr config set llm.use_anthropic false ocr config set llm.extra_body '{"thinking": {"type": "disabled"}}' diff --git a/examples/gitlab_ci/README.md b/examples/gitlab_ci/README.md index ab9461fa..70ac144a 100644 --- a/examples/gitlab_ci/README.md +++ b/examples/gitlab_ci/README.md @@ -38,7 +38,7 @@ Go to your project's **Settings → CI/CD → Variables** and add: |----------|----------|--------|-------------| | `OCR_LLM_URL` | Yes | No | LLM API endpoint URL (e.g., `https://api.openai.com/v1/chat/completions`) | | `OCR_LLM_AUTH_TOKEN` | Yes | Yes | API authentication token | -| `OCR_LLM_MODEL` | No | No | Model name (defaults to `gpt-4o`) | +| `OCR_LLM_MODEL` | Yes | No | Model name (e.g., `gpt-4o`) — OCR has no built-in default model and fails when this is unset | | `GITLAB_API_TOKEN` | No | Yes | GitLab access token with `api` scope (falls back to `CI_JOB_TOKEN` if not set) | > **Note:** GitLab CI/CD does not support variables with values shorter than 8 characters, so `use_anthropic` cannot be set as a CI variable. The pipeline sets it to `false` by default. If you need to use Anthropic Claude models, you'll need to modify the `.gitlab-ci.yml` script directly. @@ -145,11 +145,13 @@ script: - npm install -g @alibaba-group/open-code-review # Configure OCR - - mkdir -p ~/.open-code-review - | - ocr config set llm.url $OCR_LLM_URL - ocr config set llm.auth_token $OCR_LLM_AUTH_TOKEN - ocr config set llm.model $OCR_LLM_MODEL + : "${OCR_LLM_URL:?set OCR_LLM_URL in Settings -> CI/CD -> Variables}" + : "${OCR_LLM_AUTH_TOKEN:?set OCR_LLM_AUTH_TOKEN in Settings -> CI/CD -> Variables}" + : "${OCR_LLM_MODEL:?set OCR_LLM_MODEL in Settings -> CI/CD -> Variables}" + ocr config set llm.url "$OCR_LLM_URL" + ocr config set llm.auth_token "$OCR_LLM_AUTH_TOKEN" + ocr config set llm.model "$OCR_LLM_MODEL" ocr config set llm.use_anthropic false ocr config set llm.extra_body '{"thinking": {"type": "disabled"}}'