Guard edge-app create against EDGE_APP_ID, warn on stale id after delete - #316
Closed
nicomiguelino wants to merge 4 commits into
Closed
Conversation
…ter delete edge-app create and edge-app create --in-place now refuse to run while EDGE_APP_ID is set, since both always create a brand new Edge App and would otherwise leave the env var pointing at an app the user didn't mean to create. edge-app delete still clears id from screenly.yml via clear_app_id, but now also prints a warning if EDGE_APP_ID is set afterward, since it can't be cleared from the environment and would otherwise silently keep resolving to the deleted app.
There was a problem hiding this comment.
Pull request overview
This PR strengthens Edge App CLI safety around EDGE_APP_ID by preventing accidental creation while an app id is already configured, and by warning after deletion when an env-configured id may now be stale.
Changes:
- Add a shared
edge_app_id_from_env()helper (trim + whitespace-only treated as unset) and reuse it inget_app_id,create,create --in-place, and the delete flow. - Make
edge-app create/edge-app create --in-placeerror out whenEDGE_APP_IDis set, and add unit tests for the behavior. - After successful
edge-app delete, warn ifEDGE_APP_IDremains set; update docs to describe these behaviors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/commands/edge_app/app.rs |
Adds env-var helper and guards create/create_in_place; updates get_app_id; adds tests. |
src/cli.rs |
Emits a post-delete warning if EDGE_APP_ID is still set. |
docs/EdgeApps.md |
Documents the new guard/warning behavior around EDGE_APP_ID. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…st I/O EDGE_APP_ID_ENV and edge_app_id_from_env() are only used within this crate, so pub unnecessarily expanded the public API surface. In create_in_place, the EDGE_APP_ID guard now runs before reading and parsing screenly.yml, so a malformed manifest doesn't surface a YAML error instead of the intended "refuse to run while EDGE_APP_ID is set" behavior. Added a regression test with deliberately invalid YAML.
…dge-app-id-env-var-create-delete
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
src/commands/edge_app/app.rs:207
- This error message also refers to
'edge-app deploy', but the CLI is invoked asscreenly edge-app …. Using the full command name avoids confusion and matches other user-facing guidance strings.
if let Some(id) = edge_app_id_from_env() {
return Err(CommandError::InitializationError(format!(
"An Edge App id is already configured via the {EDGE_APP_ID_ENV} environment variable ({id}). The operation can only proceed when no Edge App id is already configured; unset {EDGE_APP_ID_ENV} first if you want to create a new Edge App, or use 'edge-app deploy' if you meant to deploy to the existing app."
)));
…sages The trailing period in both messages doubled up with the one cli.rs's error handler already appends, producing "...existing app..". Dropped it to match the existing convention of CommandError messages not including their own terminal punctuation. Also swapped the shorthand 'edge-app create'/'edge-app deploy' for the actual, copy-pasteable 'screenly edge-app create'/'screenly edge-app deploy' invocations.
Contributor
Author
|
Upcoming commits to #315 will supersede this pull request. |
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
edge-app createandedge-app create --in-placenow refuse to run whileEDGE_APP_IDis set. Both commands always create a brand new Edge App, so proceeding with the env var already set would leave it pointing at an app the user didn't mean to create. The error message names the current value and suggests unsettingEDGE_APP_IDor usingedge-app deployinstead.edge-app deletestill clearsidfromscreenly.ymlviaclear_app_id, unchanged. It now also prints a warning ifEDGE_APP_IDis still set afterward, since the CLI has no way to clear an environment variable on the user's behalf and would otherwise silently keep resolving to the deleted app on the next command.edge_app_id_from_env()helper (trims and treats whitespace only as unset, matching the manifest's existing validation), reused byget_app_id,create,create_in_place, and the delete flow incli.rs.docs/EdgeApps.mdunder the manifestidreference to describe both behaviors.