-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Description
The apify push command has problematic behavior when actor.json contains environment variables that reference non-existent secrets. Instead of failing with an error (which would be the expected behavior), it:
- Only shows a warning message
- Continues with the deployment
- Silently omits the environment variables that reference missing secrets
This can lead to actors being deployed in production without required environment variables, potentially causing runtime failures that are difficult to debug.
Expected Behavior
The push command should fail with a clear error message indicating that required secrets are missing, similar to how other validation errors are handled.
Actual Behavior
- Push succeeds ✅
- Shows warning: Value for NONEXISTENT_SECRET not found in local secrets. Set it by calling "apify secrets add NONEXISTENT_SECRET [SECRET_VALUE]"
⚠️ - Actor is deployed without the environment variable (silently omitted)
Root Cause
In src/lib/secrets.ts
, both replaceSecretsValue()
and transformEnvToEnvVars()
functions only emit warnings for missing secrets instead of throwing errors:
// Lines 104-106 in transformEnvToEnvVars()
} else {
warning({
message: `Value for ${secretKey} not found in local secrets. Set it by calling "apify secrets add ${secretKey} [SECRET_VALUE]"`,
});
}
Suggested Fix
The push command should fail when any referenced secrets are missing. This could be implemented by:
- Making
transformEnvToEnvVars()
throw an error instead of just warning when secrets are missing - Or adding validation in the push command to check all secret references before deployment
- Potentially adding a
--ignore-missing-secrets
flag for cases where the current behavior might be desired
Additional Context
This affects the apify push
command, the apify run
command and potentially other commands.