Skip to content

Conversation

@majiayu000
Copy link
Contributor

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

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
@vercel
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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 22, 2025

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

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

@waleedlatif1 waleedlatif1 deleted the branch simstudioai:staging December 27, 2025 05:25
@waleedlatif1 waleedlatif1 reopened this Dec 27, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants