-
Notifications
You must be signed in to change notification settings - Fork 289
feat(scripts): add .env sanity check helper #102
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
base: main
Are you sure you want to change the base?
Conversation
Provides a .env sanity-check script that validates required variables for Polymarket Agents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to Polymarket Agents. Thank you for creating your first PR. Cheers!
| continue | ||
| ;; | ||
| *) | ||
| export "${key}=${value}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoted values pass validation despite being empty
The .env.example template uses quoted empty values like KEY="". When the script parses these, the literal quote characters become part of the value, so "" is treated as a 2-character non-empty string. This causes the -z check to pass when it shouldn't. If a user copies .env.example to .env without filling in values, the script incorrectly reports all required variables as present, defeating the purpose of the sanity check.
Additional Locations (1)
| continue | ||
| ;; | ||
| *) | ||
| export "${key}=${value}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell expansion corrupts values containing dollar signs
The export "${key}=${value}" statement uses double quotes, causing shell variable expansion and command substitution in values. If an API key contains $ characters (e.g., mykey$123), the $123 portion will be expanded as a shell variable (likely empty), corrupting the value. This could cause the validation to incorrectly fail for legitimate credentials or produce misleading results.
| export "${key}=${value}" | ||
| ;; | ||
| esac | ||
| done < "${ENV_FILE}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last line skipped if file lacks trailing newline
The while IFS='=' read -r key value loop silently drops the last line of the .env file if it doesn't end with a trailing newline. The read command returns non-zero at EOF even when it successfully reads data, causing the loop to exit before processing. If a required variable is on the final line of such a file, validation would incorrectly fail. The standard fix is while read ... || [ -n "$key" ].
Provides a .env sanity-check script that validates required variables for Polymarket Agents.
Note
Introduces a minimal
.envvalidator to catch missing required configuration early.scripts/bash/check_env.shthat checks for.env, parses and exports non-comment entries, and verifiesPOLYGON_WALLET_PRIVATE_KEYandOPENAI_API_KEYWritten by Cursor Bugbot for commit da45db1. This will update automatically on new commits. Configure here.