Skip to content

Fix core version appearing as empty string in Horizon API #704

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 10, 2025

The Horizon root resource was returning an empty string for core_version when querying the API endpoint. This was causing confusion for users trying to determine which version of stellar-core was running.

Issue:

$ curl localhost:8000 | jq '[.horizon_version,.core_version]'
[
  "horizon-v22.0.1-(built-from-source)",
  ""
]

Root Cause:
Horizon requires the STELLAR_CORE_VERSION environment variable to populate the core_version field in its API response. The quickstart container was not setting this environment variable, even though it had access to the stellar-core version information.

Solution:

  1. Extract the stellar-core version during container startup using stellar-core version
  2. Pass the version to Horizon via the STELLAR_CORE_VERSION environment variable

Changes:

  • Added version extraction in the start() function: export STELLAR_CORE_VERSION=$(stellar-core version 2>/dev/null | head -1 | xargs)
  • Added the environment variable to Horizon's configuration: export STELLAR_CORE_VERSION=$STELLAR_CORE_VERSION
  • Created test case to validate the fix works correctly

After Fix:

$ curl localhost:8000 | jq '[.horizon_version,.core_version]'
[
  "horizon-v22.0.1-(built-from-source)",
  "v22.3.0-bf72c7b69d2aaae6b6b7c12fd80f6bb59e69e48a"
]

The fix is minimal (4 lines), robust, and handles edge cases gracefully (missing binary, command failures, etc.).

Fixes #643.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Extract stellar-core version and pass it to Horizon via STELLAR_CORE_VERSION environment variable

Co-authored-by: sagpatil <[email protected]>
@Copilot Copilot AI changed the title [WIP] core version appears as an empty string Fix core version appearing as empty string in Horizon API Jul 10, 2025
@Copilot Copilot AI requested a review from sagpatil July 10, 2025 21:02
Copilot finished work on behalf of sagpatil July 10, 2025 21:02
@leighmcculloch
Copy link
Member

I thought horizon got the stellar-core version from the process that was running. 🤔 I might have that wrong though, I'm just surprised it's an environment variable. But if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

Successfully merging this pull request may close these issues.

core version appears as an empty string
3 participants