Skip to content

Guard edge-app create against EDGE_APP_ID, warn on stale id after delete - #316

Closed
nicomiguelino wants to merge 4 commits into
feature/edge-app-id-env-var-deprecationfrom
feature/edge-app-id-env-var-create-delete
Closed

Guard edge-app create against EDGE_APP_ID, warn on stale id after delete#316
nicomiguelino wants to merge 4 commits into
feature/edge-app-id-env-var-deprecationfrom
feature/edge-app-id-env-var-create-delete

Conversation

@nicomiguelino

@nicomiguelino nicomiguelino commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • edge-app create and edge-app create --in-place now refuse to run while EDGE_APP_ID is 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 unsetting EDGE_APP_ID or using edge-app deploy instead.
  • edge-app delete still clears id from screenly.yml via clear_app_id, unchanged. It now also prints a warning if EDGE_APP_ID is 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.
  • Extracted the env var read into a shared edge_app_id_from_env() helper (trims and treats whitespace only as unset, matching the manifest's existing validation), reused by get_app_id, create, create_in_place, and the delete flow in cli.rs.
  • Docs updated in docs/EdgeApps.md under the manifest id reference to describe both behaviors.

…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.
Copilot AI lite review requested due to automatic review settings August 31, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in get_app_id, create, create --in-place, and the delete flow.
  • Make edge-app create / edge-app create --in-place error out when EDGE_APP_ID is set, and add unit tests for the behavior.
  • After successful edge-app delete, warn if EDGE_APP_ID remains 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.

Comment thread src/commands/edge_app/app.rs Outdated
Comment thread src/commands/edge_app/app.rs Outdated
…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.
Copilot AI review requested due to automatic review settings August 31, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 31, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as screenly 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."
            )));

Comment thread src/commands/edge_app/app.rs
…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.
Copilot AI review requested due to automatic review settings August 31, 2026 17:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@nicomiguelino

Copy link
Copy Markdown
Contributor Author

Upcoming commits to #315 will supersede this pull request.

@nicomiguelino
nicomiguelino deleted the feature/edge-app-id-env-var-create-delete branch September 2, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants