Add git commit hash to /version endpoint response#946
Conversation
- APP_VERSION -> "0.9.9 RC"
- Add SharedState.commitHash, resolved once at boot from NODE_VERSION
(.git/HEAD or GIT_COMMIT override), for tamper verification
- /version now returns { version, commit } instead of a bare string
- Update openapi-spec for the new /version JSON shape
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ZdtuWdzFZWLTj6URHsG9h
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
More reviews will be available in 50 minutes and 17 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe ChangesVersion Endpoint Commit Hash Exposure
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/libs/network/openapi-spec.json (1)
128-139: ⚡ Quick winDeclare
/versionfields as required in the schema.
versionandcommitare always present at runtime (withcommitpossiblynull), so marking them required improves generated client types and prevents optional-field drift.Suggested diff
"schema": { "type": "object", "properties": { "version": { "type": "string" }, "commit": { "type": "string", "nullable": true, "description": "Git commit hash of the running binary, or null if unresolvable." } - } + }, + "required": ["version", "commit"] }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/libs/network/openapi-spec.json` around lines 128 - 139, The OpenAPI schema for the `/version` endpoint response object does not explicitly mark the version and commit properties as required. Add a "required" array to the object schema (at the same level as the "properties" field) that includes both "version" and "commit" to indicate these fields must always be present in the response, even though commit may be null. This will ensure generated client types properly reflect that these fields are always provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/libs/network/openapi-spec.json`:
- Around line 128-139: The OpenAPI schema for the `/version` endpoint response
object does not explicitly mark the version and commit properties as required.
Add a "required" array to the object schema (at the same level as the
"properties" field) that includes both "version" and "commit" to indicate these
fields must always be present in the response, even though commit may be null.
This will ensure generated client types properly reflect that these fields are
always provided.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 305e058f-1307-4596-8807-d79ae8a88e13
📒 Files selected for processing (4)
src/libs/network/openapi-spec.jsonsrc/libs/network/server_rpc.tssrc/utilities/constants.tssrc/utilities/sharedState.ts
Greptile SummaryThis PR enhances the
Confidence Score: 4/5Safe to merge with one fix: findRepoRoot should start from import.meta.url rather than process.cwd() to match the reliability guarantee already built into the same file's package.json walker. In production scenarios where the process CWD is not the repo root (the exact failure case the readPackageJson comment describes with dev.node2), findRepoRoot(process.cwd()) returns null immediately and every /version response reports commit: null. The rest of the change — endpoint shape, OpenAPI spec, SharedState wiring, version bump — is straightforward and correct. src/utilities/nodeVersion.ts — specifically the findRepoRoot starting path. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Boot as Module Evaluation (startup)
participant NV as nodeVersion.ts
participant FS as Filesystem (.git/HEAD)
participant ENV as Environment (GIT_COMMIT)
participant SS as SharedState
participant Client as HTTP Client
Boot->>NV: import NODE_VERSION
NV->>ENV: check GIT_COMMIT env var
alt GIT_COMMIT set and valid
ENV-->>NV: commit SHA (validated hex)
else no env var
NV->>FS: findRepoRoot(process.cwd())
FS-->>NV: repoRoot or null
alt repoRoot found
NV->>FS: read .git/HEAD
FS-->>NV: ref or detached SHA
NV->>FS: read ref file or packed-refs
FS-->>NV: commit SHA
else no repo
NV-->>NV: "commit = null"
end
end
NV-->>SS: NODE_VERSION.commit
SS->>SS: "commitHash = NODE_VERSION.commit"
Client->>+SS: GET /version
SS-->>-Client: version and commit or null
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Boot as Module Evaluation (startup)
participant NV as nodeVersion.ts
participant FS as Filesystem (.git/HEAD)
participant ENV as Environment (GIT_COMMIT)
participant SS as SharedState
participant Client as HTTP Client
Boot->>NV: import NODE_VERSION
NV->>ENV: check GIT_COMMIT env var
alt GIT_COMMIT set and valid
ENV-->>NV: commit SHA (validated hex)
else no env var
NV->>FS: findRepoRoot(process.cwd())
FS-->>NV: repoRoot or null
alt repoRoot found
NV->>FS: read .git/HEAD
FS-->>NV: ref or detached SHA
NV->>FS: read ref file or packed-refs
FS-->>NV: commit SHA
else no repo
NV-->>NV: "commit = null"
end
end
NV-->>SS: NODE_VERSION.commit
SS->>SS: "commitHash = NODE_VERSION.commit"
Client->>+SS: GET /version
SS-->>-Client: version and commit or null
Reviews (2): Last reviewed commit: "Update src/libs/network/openapi-spec.jso..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
Enhanced the
/versionendpoint to return structured JSON with both version and git commit information, improving deployment tracking and verification capabilities.Key Changes
/versionendpoint response from plain text string to JSON object containingversionandcommitfieldscommitHashproperty toSharedStatethat captures the git commit hash of the running binary at boot timenodeVersionutility module to resolve git commit information from.git/HEADorGIT_COMMITenvironment variableAPP_VERSIONfrom "0.9.8" to "0.9.9 RC"Implementation Details
SharedState.commitHashnullif unresolvable (e.g., stripped Docker images without.git/directory and noGIT_COMMITbuild argument)/versionendpoint now returns a JSON object with the structure:{ "version": "0.9.9 RC", "commit": "<git-hash-or-null>" }https://claude.ai/code/session_015ZdtuWdzFZWLTj6URHsG9h
Summary by CodeRabbit
New Features
Chores