Skip to content
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
16 changes: 13 additions & 3 deletions Video/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,19 @@ else
echo "$(date -u +"${ts_format}") [${process_name}] - Start recording: $caps_se_video_record, video file name: $video_file_name"
log_node_response
if [[ "${SE_VIDEO_SESSION_SUBFOLDER}" = "true" ]]; then
video_dir="${VIDEO_FOLDER}/${session_id}"
mkdir -p "${video_dir}"
echo "$(date -u +"${ts_format}") [${process_name}] - Created session subfolder: ${video_dir}"
# Group each recording under its session id. If the session id is empty for any reason,
# fall back to the Node container/Pod name so the video still lands in a unique subfolder.
subfolder_key="${session_id}"
if [ -z "${subfolder_key}" ] || [ "${subfolder_key}" = "null" ]; then
subfolder_key="${SE_NODE_CONTAINER_NAME}"
fi
if [ -n "${subfolder_key}" ]; then
video_dir="${VIDEO_FOLDER}/${subfolder_key}"
Comment on lines +278 to +283

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Informational

2. Shell fallback unreachable 🐞 Bug ⚙ Maintainability

In video.sh, the recording block is only entered when session_id is already non-empty and not
"null", so the new fallback check for empty/"null" will never be true in that code path. This makes
the added fallback logic dead code and may give a false sense that empty session ids are handled.
Agent Prompt
## Issue description
The new `SE_NODE_CONTAINER_NAME` fallback logic inside the recording-start block is unreachable because the surrounding condition already guarantees `session_id` is neither empty nor `"null"`. This adds complexity without changing behavior.

## Issue Context
The outer condition checks:
- `session_id != "null"`
- `session_id != ""`
so `subfolder_key="${session_id}"` cannot be empty/"null" when the fallback `if` runs.

## Fix Focus Areas
- Video/video.sh[263-291]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

mkdir -p "${video_dir}"
echo "$(date -u +"${ts_format}") [${process_name}] - Created session subfolder: ${video_dir}"
else
video_dir="${VIDEO_FOLDER}"
fi
else
video_dir="${VIDEO_FOLDER}"
fi
Expand Down
13 changes: 9 additions & 4 deletions Video/video_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,15 @@ async def handle_session_created(self, data: dict) -> None:
record_video, video_filename = self.get_video_filename(session_id, capabilities)

if record_video and self.session_subfolder:
session_subdir = Path(self.video_folder) / session_id
session_subdir.mkdir(parents=True, exist_ok=True)
video_filename = f"{session_id}/{video_filename}"
logger.info(f"Created session subfolder: {session_subdir}")
# Group each recording under its session id. If the session id is empty for any reason,
# fall back to the Node container/Pod name so the video still lands in a unique subfolder
# (important on Kubernetes where the assets volume is shared across Pods).
subfolder_key = session_id or os.environ.get("SE_NODE_CONTAINER_NAME", "").strip()
if subfolder_key:
session_subdir = Path(self.video_folder) / subfolder_key
session_subdir.mkdir(parents=True, exist_ok=True)
video_filename = f"{subfolder_key}/{video_filename}"
Comment on lines +774 to +778

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

1. Python fallback unreachable 🐞 Bug ≡ Correctness

In video_service.py, handle_session_created returns early when sessionId is falsy, so `subfolder_key
= session_id or SE_NODE_CONTAINER_NAME` can never select the container name for empty/missing
session ids. Additionally, because the code doesn’t normalize the common sentinel string "null" for
sessionId, the fallback also won’t trigger for that case (it will still use "null" as the folder).
Agent Prompt
## Issue description
`handle_session_created()` aims to fall back to `SE_NODE_CONTAINER_NAME` when the session id is missing/empty, but the current control flow returns early for falsy `sessionId`, making the fallback unreachable for the primary “empty session id” case. It also does not treat the sentinel string `"null"` (used elsewhere in this file for capability fields) as missing.

## Issue Context
- `handle_session_created()` currently does `if not session_id: ... return`, so `session_id or ...` cannot ever use the env var for empty/None.
- Other parts of the service already treat `"null"` as a sentinel string (e.g., capability-derived names), so normalizing `sessionId` similarly keeps behavior consistent.
- If you decide to use a fallback-derived key for state tracking, you must apply the same normalization in `handle_session_closed()` (and any other handler indexing `self.sessions`) so stop/cleanup can find the correct entry.

## Fix Focus Areas
- Video/video_service.py[755-780]
- Video/video_service.py[806-833]
- Video/video_service.py[296-312]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

logger.info(f"Created session subfolder: {session_subdir}")

retain_on_failure_cap = capabilities.get("se:retainOnFailure", None)
if retain_on_failure_cap is None:
Expand Down
Loading