Skip to content

Script Runner File Locks Not Respected if File Opened Via URL #3557

Description

@shonigmann

Describe the bug

We noticed that file locks are not respected if a user accesses a script file directly via a URL rather than through the built-in File -> Open dialog

Claude dispositioning below:

  File → Open (via FileOpenSaveDialog):
  - openSuccess() calls Api.get('/script-api/scripts/${file}') → server auto-locks
  - Emits 'file' event → ScriptRunner calls setFile(data) with local = false (default)
  - In setFile with local = false: lockedBy is updated from the response → UI shows lock warning
  URL open (?file=...):
  - mounted() sets this.filename then calls reloadFile()
  - reloadFile() calls Api.get(...) → server auto-locks
  - Then calls setFile(data, true) with local = true ← this is the problem
  - In setFile, the if (local === false) block is entirely skipped → lockedBy is never updated
  - UI shows no lock warning even if another user holds the lock
  This is a real bug. reloadFile() always passes local = true to setFile, which was intended to mean "don't unlock the old file before switching" (since it's reloading the same file), but the side effect is that lock state from the
  response is silently discarded.

To Reproduce

  1. Enable script file locks in the admin console
  2. Open a script via the file open dialog in one window
  3. In a new window, reopen that script via the file open dialog, confirm it is locked
  4. Copy the URL for the script (e.g. https://.com/tools/scriptrunner?file=) In a new window. The file does not appear locked

Expected behavior

The file is locked by the original user

Screenshots

No response

OS

No response

OpenC3 COSMOS Version

7.2.0

Browser

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageMore information is needed

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions