Skip to content
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

Issue #168: Need better error message when using invalid character wh… #171

Merged
merged 1 commit into from
Jan 18, 2024
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
4 changes: 4 additions & 0 deletions src/commands/env/create/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = async function action (params) {
let { access_token: token, stagingAPI: _staging } = config
let client = require('@begin/api')
let error = require('../errors')(params)
let looseName = /^[a-zA-Z_][a-zA-Z0-9_]+$/

// Environment (required)
let env = args.env || args.e
Expand All @@ -21,6 +22,9 @@ module.exports = async function action (params) {
if (!name || name === true) {
return error('no_name')
}
if (!looseName.test(name) || name.length > 64) {
return error('invalid_varname')
}
name = name.toUpperCase()

// Value (required)
Expand Down
1 change: 1 addition & 0 deletions src/commands/env/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function error (params) {
no_appid: 'App ID not found, please run with -a or --appID',
no_env: 'Environment ID not found, please run with -e or --envID',
no_name: 'Variable name not found, please run with -n or --name',
invalid_varname: 'Environment variable names can consist of up to 64 characters. The name can contain upper and lowercase letters, numbers, and underscores (_), but it must start with a letter or underscore.',
no_value: 'Variable value not found, please run with -v or --value',
create_fail: 'Failed to create environment variable',
destroy_fail: 'Failed to destroy environment variable',
Expand Down