Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(api): add version endpoint for instance identification #2520

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

Open
majiayu000 wants to merge 8 commits into simstudioai:staging
base: staging
Choose a base branch
Loading
from majiayu000:fix/show-version

Conversation

@majiayu000
Copy link
Contributor

@majiayu000 majiayu000 commented Dec 22, 2025

Summary

  • Add GET /api/version endpoint that returns version information
  • Returns app version, name, build time, git commit, and environment
  • Helps identify the version of a running Sim Studio instance

Test plan

  • Manual testing with curl /api/version

Fixes #2014

greptile-apps[bot] reacted with thumbs up emoji
icecrasher321 and others added 8 commits December 18, 2025 16:23
...dioai#2481)
The realtime service network policy was missing the custom egress rules section
that allows configuration of additional egress rules via values.yaml. This caused
the realtime pods to be unable to connect to external databases (e.g., PostgreSQL
on port 5432) when using external database configurations.
The app network policy already had this section, but the realtime network policy
was missing it, creating an inconsistency and preventing the realtime service
from accessing external databases configured via networkPolicy.egress values.
This fix adds the same custom egress rules template section to the realtime
network policy, matching the app network policy behavior and allowing users to
configure database connectivity via values.yaml.
Adds GET /api/version endpoint that returns:
- Application version
- Application name
- Build time (if available)
- Git commit hash (if available)
- Node environment
This helps users identify the version of a running Sim Studio instance.
Fixes simstudioai#2014 
Copy link

vercel bot commented Dec 22, 2025

@majiayu000 is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

greptile-apps bot commented Dec 22, 2025
edited
Loading

Greptile Summary

Added a new GET /api/version endpoint to expose version information for running Sim Studio instances, addressing issue #2014.

Changes:

  • New public API endpoint returns version, name, build time, git commit, and environment
  • Endpoint uses force-dynamic to prevent caching

Issues Found:

  • process.env.npm_package_version will be undefined at runtime (npm package env vars only exist during script execution)
  • Build-time environment variables (BUILD_TIME, GIT_COMMIT, APP_VERSION) are not configured in the Docker build process, so they will always return null
  • These env vars need to be added as build args in docker/app.Dockerfile and passed during CI/CD image builds

Confidence Score: 2/5

  • This PR has implementation issues that prevent it from working as intended
  • The endpoint code is well-structured and follows Next.js patterns, but has critical runtime issues: npm_package_version will be undefined at runtime, and the Docker build process doesn't set the required environment variables (BUILD_TIME, GIT_COMMIT, APP_VERSION), causing the endpoint to return mostly null values instead of actual version information
  • The version endpoint needs Docker build configuration updates to work properly

Important Files Changed

Filename Overview
apps/sim/app/api/version/route.ts Adds version endpoint, but environment variables for build metadata are not configured in Docker build process

Sequence Diagram

sequenceDiagram
 participant Client
 participant API as GET /api/version
 participant Env as Environment Variables
 
 Client->>API: HTTP GET /api/version
 API->>Env: Read APP_VERSION
 Env-->>API: process.env.npm_package_version || process.env.APP_VERSION || '0.1.0'
 API->>Env: Read BUILD_TIME
 Env-->>API: process.env.BUILD_TIME || null
 API->>Env: Read GIT_COMMIT
 Env-->>API: process.env.VERCEL_GIT_COMMIT_SHA || process.env.GIT_COMMIT || null
 API->>Env: Read NODE_ENV
 Env-->>API: process.env.NODE_ENV
 API->>API: Format git commit (first 7 chars)
 API->>Client: JSON response {version, name, buildTime, gitCommit, nodeEnv}
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. apps/sim/app/api/version/route.ts, line 22 (link)

    logic: exposing NODE_ENV could reveal whether the instance is in development/staging/production, which may aid attackers in reconnaissance

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (2)

  1. apps/sim/app/api/version/route.ts, line 6 (link)

    logic: process.env.npm_package_version is undefined at runtime in Next.js. npm_package_* variables are only available during npm script execution, not in the deployed app.

  2. apps/sim/app/api/version/route.ts, line 14-15 (link)

    logic: Environment variables BUILD_TIME, GIT_COMMIT, and APP_VERSION need to be set during Docker build. Add build args to docker/app.Dockerfile:

    ARG BUILD_TIME
    ARG GIT_COMMIT
    ARG APP_VERSION
    ENV BUILD_TIME=${BUILD_TIME}
    ENV GIT_COMMIT=${GIT_COMMIT}
    ENV APP_VERSION=${APP_VERSION}
    

    And pass them in .github/workflows/images.yml build step.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /