Add support for default project ID via config and environment#23
Merged
Add support for default project ID via config and environment#23
Conversation
Allow the project ID to be provided via the HONEYBADGER_PROJECT_ID environment variable as a fallback when the --project-id flag is not set. This follows the same pattern used by HONEYBADGER_API_KEY and HONEYBADGER_AUTH_TOKEN, leveraging Viper's AutomaticEnv with the HONEYBADGER prefix. Updated all commands that accept --project-id (faults, check-ins, comments, deployments, environments, insights, uptime) to check viper for the project_id config key when the flag value is zero. Also removed MarkFlagRequired for project-id in insights since the value can now come from the environment. https://claude.ai/code/session_01WT7m3r3dcygQtJYdacCnN7
Add project_id to the config file example and HONEYBADGER_PROJECT_ID to the environment variables section. https://claude.ai/code/session_01WT7m3r3dcygQtJYdacCnN7
Break the project ID error message across multiple lines to satisfy the golines line-length linter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a “default project ID” mechanism for Data API commands so users don’t need to pass --project-id on every invocation, by falling back to project_id from Viper config / HONEYBADGER_PROJECT_ID.
Changes:
- Added per-command fallback logic: if
--project-idis unset/0, readproject_idfrom configuration. - Updated “missing project ID” validation errors and removed the
project-idrequired-flag constraint forinsights query. - Updated README configuration + environment variable examples to include
project_id/HONEYBADGER_PROJECT_ID.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/checkins.go | Adds project ID fallback to project_id before validating presence. |
| cmd/comments.go | Adds project ID fallback to project_id before validating presence. |
| cmd/deployments.go | Adds project ID fallback to project_id before validating presence. |
| cmd/environments.go | Adds project ID fallback to project_id before validating presence. |
| cmd/faults.go | Adds project ID fallback to project_id before validating presence. |
| cmd/insights.go | Adds project ID fallback + removes project-id as a required flag. |
| cmd/uptime.go | Adds project ID fallback to project_id before validating presence. |
| README.md | Documents new project_id config key and HONEYBADGER_PROJECT_ID env var. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback: - Extract repeated project ID resolution into resolveProjectID() helper - Update error message to mention config file as a valid source - Add test coverage for viper config fallback path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The project_id key was never registered with viper (unlike api_key,
auth_token, and endpoint which are bound via BindPFlag). Without
registration, viper.GetInt("project_id") with AutomaticEnv doesn't
find the HONEYBADGER_PROJECT_ID environment variable.
Add viper.BindEnv("project_id") in initConfig to explicitly register
the key for env var lookup.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
joshuap
approved these changes
Feb 11, 2026
Member
joshuap
left a comment
There was a problem hiding this comment.
This should work with hbtui as well. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for configuring a default project ID through configuration files and environment variables, eliminating the need to specify
--project-idflag for every command that requires it.Key Changes
project_idconfiguration option to YAML config files andHONEYBADGER_PROJECT_IDenvironment variable support--project-idflag is not providedcmd/checkins.go(5 commands)cmd/comments.go(5 commands)cmd/deployments.go(3 commands)cmd/environments.go(5 commands)cmd/faults.go(5 commands)cmd/insights.go(1 command, also removed redundant flag requirement)cmd/uptime.go(7 commands)Implementation Details
GetInt("project_id")to retrieve the configured default valuehttps://claude.ai/code/session_01WT7m3r3dcygQtJYdacCnN7