Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
git clone https://${{ secrets.GH_PAT }}@github.com/paperdebugger/deploy.git ../deploy
- name: Generate kubernetes manifests
env:
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL_PRD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_PRD }}
MCP_BASIC_KEY: ${{ secrets.MCP_BASIC_KEY_PRD }}
MCP_PAPERSCORE_KEY: ${{ secrets.MCP_PAPERSCORE_KEY_PRD }}
Expand Down
2 changes: 2 additions & 0 deletions hack/prd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euxo pipefail
ROOT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)
cd $ROOT_DIR

OPENAI_BASE_URL=${OPENAI_BASE_URL:-https://api.openai.com/v1}
OPENAI_API_KEY=${OPENAI_API_KEY:-sk-dummy-OPENAI_API_KEY}
MCP_BASIC_KEY=${MCP_BASIC_KEY:-sk-dummy-MCP_BASIC_KEY}
MCP_PAPERSCORE_KEY=${MCP_PAPERSCORE_KEY:-sk-dummy-MCP_PAPERSCORE_KEY}
Expand All @@ -21,6 +22,7 @@ helm template $ROOT_DIR/helm-chart \
--create-namespace \
--values $ROOT_DIR/helm-chart/values.yaml \
--values $ROOT_DIR/hack/values-prd.yaml \
--set-string openai_base_url=$OPENAI_BASE_URL \
--set-string openai_api_key=$OPENAI_API_KEY \
--set-string mcp_basic_key=$MCP_BASIC_KEY \
--set-string mcp_paperscore_key=$MCP_PAPERSCORE_KEY \
Expand Down
2 changes: 2 additions & 0 deletions hack/stg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euxo pipefail
ROOT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)
cd $ROOT_DIR

OPENAI_BASE_URL=${OPENAI_BASE_URL:-https://api.openai.com/v1}
OPENAI_API_KEY=${OPENAI_API_KEY:-sk-dummy-OPENAI_API_KEY}
MCP_BASIC_KEY=${MCP_BASIC_KEY:-sk-dummy-MCP_BASIC_KEY}
MCP_PAPERSCORE_KEY=${MCP_PAPERSCORE_KEY:-sk-dummy-MCP_PAPERSCORE_KEY}
Expand All @@ -21,6 +22,7 @@ helm template $ROOT_DIR/helm-chart \
--create-namespace \
--values $ROOT_DIR/helm-chart/values.yaml \
--values $ROOT_DIR/hack/values-stg.yaml \
--set-string openai_base_url=$OPENAI_BASE_URL \
--set-string openai_api_key=$OPENAI_API_KEY \
--set-string mcp_basic_key=$MCP_BASIC_KEY \
--set-string mcp_paperscore_key=$MCP_PAPERSCORE_KEY \
Expand Down
1 change: 1 addition & 0 deletions helm-chart/templates/paperdebugger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ metadata:
name: paperdebugger
namespace: {{ .Values.namespace }}
data:
OPENAI_BASE_URL: "{{ .Values.openai_base_url }}"
OPENAI_API_KEY: "{{ .Values.openai_api_key }}"
JWT_SIGNING_KEY: "{{ .Values.jwt_signing_key }}"
{{ if not .Values.mongo.in_cluster }}
Expand Down
1 change: 1 addition & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace: paperdebugger-dev
openai_base_url: https://api.openai.com/v1
openai_api_key: sk-dummy-OPENAI_API_KEY
jwt_signing_key: paperdebugger
ghcr_docker_config: dummy-ghcr-docker-config
Expand Down
10 changes: 10 additions & 0 deletions internal/libs/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

type Cfg struct {
OpenAIBaseURL string
OpenAIAPIKey string
JwtSigningKey string

Expand All @@ -19,6 +20,7 @@ var cfg *Cfg
func GetCfg() *Cfg {
_ = godotenv.Load()
cfg = &Cfg{
OpenAIBaseURL: openAIBaseURL(),
OpenAIAPIKey: os.Getenv("OPENAI_API_KEY"),
JwtSigningKey: os.Getenv("JWT_SIGNING_KEY"),
MongoURI: mongoURI(),
Expand All @@ -28,6 +30,14 @@ func GetCfg() *Cfg {
return cfg
}

func openAIBaseURL() string {
val := os.Getenv("OPENAI_BASE_URL")
if val != "" {
return val
}
return "https://api.openai.com/v1"
}
Comment on lines +33 to +39
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The new OpenAIBaseURL field and openAIBaseURL() helper function lack test coverage. The existing test file cfg_test.go validates other configuration fields (MongoURI, JwtSigningKey, OpenAIAPIKey) but doesn't include assertions for the new OpenAIBaseURL field.

Consider adding test coverage similar to the existing assertions:

assert.NotNil(t, cfg.OpenAIBaseURL)
assert.NotEmpty(t, cfg.OpenAIBaseURL)

Additionally, consider testing both the default value and custom value scenarios for the openAIBaseURL() function to ensure it correctly falls back to the default when the environment variable is not set.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +39
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The openAIBaseURL() function doesn't trim whitespace from the environment variable value. If a user accidentally includes leading/trailing whitespace in the OPENAI_BASE_URL environment variable, it could cause API connection issues.

Consider applying strings.TrimSpace() to the value before returning it, consistent with how other URL values might be handled:

func openAIBaseURL() string {
	val := os.Getenv("OPENAI_BASE_URL")
	if val != "" {
		return strings.TrimSpace(val)
	}
	return "https://api.openai.com/v1"
}

Note: You'll need to import "strings" if not already imported.

Copilot uses AI. Check for mistakes.

func xtraMCPURI() string {
val := os.Getenv("XTRAMCP_URI")
if val != "" {
Expand Down
3 changes: 3 additions & 0 deletions internal/libs/cfg/cfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

func init() {
os.Setenv("PD_MONGO_URI", "mongodb://localhost:27017")
os.Setenv("OPENAI_BASE_URL", "https://dummy.openai.com/v1")
os.Setenv("OPENAI_API_KEY", "dummy OPENAI_API_KEY for testing")
os.Setenv("JWT_SIGNING_KEY", "dummy JWT_SIGNING_KEY for testing")
}
Expand All @@ -22,9 +23,11 @@ func TestCfg(t *testing.T) {

assert.NotNil(t, cfg.MongoURI)
assert.NotNil(t, cfg.JwtSigningKey)
assert.NotNil(t, cfg.OpenAIBaseURL)
assert.NotNil(t, cfg.OpenAIAPIKey)

assert.NotEmpty(t, cfg.JwtSigningKey)
assert.NotEmpty(t, cfg.OpenAIBaseURL)
assert.NotEmpty(t, cfg.OpenAIAPIKey)
assert.NotEmpty(t, cfg.MongoURI)
}
1 change: 1 addition & 0 deletions internal/services/toolkit/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewAIClient(
) *AIClient {
database := db.Database("paperdebugger")
oaiClient := openai.NewClient(
option.WithBaseURL(cfg.OpenAIBaseURL),
option.WithAPIKey(cfg.OpenAIAPIKey),
)
CheckOpenAIWorks(oaiClient, logger)
Expand Down