Skip to content

[WIP] chore: Recording script cleanup - #25131

Closed
defnull wants to merge 4 commits into
bigbluebutton:v3.0.x-developfrom
defnull:defnull-rap-cleanup
Closed

defnull wants to merge 4 commits into
bigbluebutton:v3.0.x-developfrom
defnull:defnull-rap-cleanup

Conversation

@defnull

@defnull defnull commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR refactors multiple recording scripts and replaces some outdated file handling patterns with more modern (and more clean) alternatives. It also replaces all YAML::load calls with YAML::safe_load to avoid code checker warnings. This is not necessary for security though, as we only load trusted files.

Motivation

The recording scripts really need some work and we have to start somewhere.

Notes

defnull added 2 commits May 22, 2026 01:14
When File.new() or File.open() is used without a code block, the file handle stays open until closed explicitly. Leaked file handles can cause issues on some file systems (e.g. NFS) when cleanup logic tries to delete the parent directory.

This patch replaces all obvious read-only uses of File.new() or File.open() with File.read().
Replace outdated file writing patterens (e.g. File.new + write + close or File.open{|f| f.write}) with a single File.write() call where possible.
@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 596645ca-1592-4f1f-a866-f75d738e2c43

📥 Commits

Reviewing files that changed from the base of the PR and between baaea29 and 7f7ba86.

📒 Files selected for processing (1)
  • record-and-playback/core/lib/recordandplayback/edl/audio.rb

Walkthrough

This pull request updates record-and-playback scripts and libraries to use YAML::safe_load with File.read, Nokogiri::XML(File.read(...)), JSON.parse(File.read(...)), and File.write in place of file-handle-based loading and writing patterns. The changes span core libraries, archive/startup scripts, runtime helpers, and format-specific process/publish scripts for notes, podcast, presentation, screenshare, and video.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: prlanzarin

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main theme of the PR: cleanup of recording scripts and file-handling updates.
Description check ✅ Passed The description is clearly about refactoring recording scripts and replacing YAML/file-handling patterns.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@record-and-playback/core/scripts/archive/archive.rb`:
- Line 305: The string written to archive_norecord_file in the File.write call
is missing a closing parenthesis, causing incorrect output; update the
File.write invocation that uses archive_norecord_file and meeting_id to include
the closing ")" so the message becomes "Archived #{meeting_id} (no recording
marks)". Ensure you modify the call that constructs that exact string to restore
the matching parenthesis.

In
`@record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb`:
- Around line 176-177: Replace the use of JSON.load when re-reading the file
with JSON.parse to match the write/read round-trip; specifically change the
read/parse of data_json_path where data is assigned (currently data =
JSON.load(File.read(data_json_path))) to use
JSON.parse(File.read(data_json_path)) so that the parsed result of
events_data.to_json is produced with the stricter parse API.

In `@record-and-playback/core/scripts/rap-caption-inbox.rb`:
- Around line 117-119: Replace the interpolated JSON string with a proper JSON
encoder: require 'json' if not present, build a Ruby array/hash using
new_caption_info (e.g. [{ "localeName" => new_caption_info["label"], "locale" =>
new_caption_info["lang"] }]) and call JSON.generate (or .to_json) when writing
to caption_json_file inside the File.open block so values are escaped correctly
instead of using file.puts with an interpolated string.

In `@record-and-playback/core/scripts/utils/captions.rb`:
- Line 57: Replace the use of JSON.load with JSON.parse when reading
captions_playback.json: locate the line that assigns captions using
JSON.load(File.read("#{captions_meeting_dir}/captions_playback.json")) and
change it to call JSON.parse on the file contents (keep the captions variable
and captions_meeting_dir usage), ensuring the plain JSON is parsed without Ruby
object deserialization.

In `@record-and-playback/screenshare/scripts/process/screenshare.rb`:
- Line 167: The line creating an unused variable using JSON.load should be
changed to use JSON.parse and drop the unused assignment: replace the call
JSON.load(File.read("#{process_dir}/captions.json")) with a plain
JSON.parse(File.read("#{process_dir}/captions.json")) invocation (or remove the
assignment entirely and just call JSON.parse(...) to validate the file) so the
code uses the safer parser and the unused variable captions is not created.

In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Line 77: Replace uses of JSON.load when reading captions.json with JSON.parse
to avoid unsafe object deserialization; specifically change the expression that
sets the captions variable (captions =
JSON.load(File.read("#{process_dir}/captions.json"))) to use
JSON.parse(File.read(...)) in the publish screenshare script, and apply the same
replacement in the process screenshare script where captions.json is read so
both instances use JSON.parse instead of JSON.load.
- Around line 40-41: The YAML safe_load call for screenshare_props is failing
because screenshare.yml uses symbol keys (formats entries like :extension);
update the loading so symbols are permitted or keys become strings: either call
YAML.safe_load(File.read(...), permitted_classes: [Symbol]) (or
permitted_symbols appropriately) when assigning screenshare_props (and keep
using format[:extension]), or change the YAML to use string keys and access
format['extension'] where format is referenced; also replace JSON.load(...) with
JSON.parse(...) when reading captions to follow best practice.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eb4bba54-897b-454c-80c3-83da5c2eede2

📥 Commits

Reviewing files that changed from the base of the PR and between 3683674 and 8f69dea.

📒 Files selected for processing (30)
  • record-and-playback/core/lib/recordandplayback.rb
  • record-and-playback/core/lib/recordandplayback/edl/audio.rb
  • record-and-playback/core/lib/recordandplayback/events_archiver.rb
  • record-and-playback/core/lib/recordandplayback/generators/audio_processor.rb
  • record-and-playback/core/lib/recordandplayback/generators/events.rb
  • record-and-playback/core/lib/recordandplayback/generators/presentation.rb
  • record-and-playback/core/lib/recordandplayback/generators/video.rb
  • record-and-playback/core/lib/recordandplayback/workers/events_worker.rb
  • record-and-playback/core/scripts/archive/archive.rb
  • record-and-playback/core/scripts/bbb-0.9-beta-recording-update
  • record-and-playback/core/scripts/bbb-0.9-recording-size
  • record-and-playback/core/scripts/bbb-1.1-meeting-tag
  • record-and-playback/core/scripts/post_events/post_events.rb.example
  • record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb
  • record-and-playback/core/scripts/rap-caption-inbox.rb
  • record-and-playback/core/scripts/rap-process-worker.rb
  • record-and-playback/core/scripts/sanity/sanity.rb
  • record-and-playback/core/scripts/utils/captions.rb
  • record-and-playback/core/test/recordandplayback/generators/test_events.rb
  • record-and-playback/notes/scripts/process/notes.rb
  • record-and-playback/notes/scripts/publish/notes.rb
  • record-and-playback/podcast/scripts/process/podcast.rb
  • record-and-playback/podcast/scripts/publish/podcast.rb
  • record-and-playback/presentation/scripts/caption/presentation
  • record-and-playback/presentation/scripts/process/presentation.rb
  • record-and-playback/presentation/scripts/publish/presentation.rb
  • record-and-playback/screenshare/scripts/process/screenshare.rb
  • record-and-playback/screenshare/scripts/publish/screenshare.rb
  • record-and-playback/video/scripts/process/video.rb
  • record-and-playback/video/scripts/publish/video.rb

File.open(archive_norecord_file, "w") do |archive_norecord|
archive_norecord.write("Archived #{meeting_id} (no recording marks")
end
File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks")

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Close the norecord status message parenthesis.

Line 305 writes "Archived #{meeting_id} (no recording marks" (missing )), which can break exact string matching in downstream tooling.

Suggested fix
-  File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks")
+  File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks)")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks")
File.write(archive_norecord_file, "Archived #{meeting_id} (no recording marks)")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/core/scripts/archive/archive.rb` at line 305, The string
written to archive_norecord_file in the File.write call is missing a closing
parenthesis, causing incorrect output; update the File.write invocation that
uses archive_norecord_file and meeting_id to include the closing ")" so the
message becomes "Archived #{meeting_id} (no recording marks)". Ensure you modify
the call that constructs that exact string to restore the matching parenthesis.

Comment on lines +117 to +119
File.open(caption_json_file, 'w') do |file|
file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]"
end

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"

echo "== File exists? =="
ls -l "$FILE"

echo
echo "== Lines 80-160 (context) =="
nl -ba "$FILE" | sed -n '80,160p'

echo
echo "== Search for caption_json_file usage =="
rg -n "caption_json_file" -S "$FILE"

echo
echo "== Search for JSON usage / requires in this file =="
rg -n "\brequire\s+['\"]json['\"]|JSON\." "$FILE" || true

echo
echo "== Find where new_caption_info is built (best-effort) =="
rg -n "new_caption_info" "$FILE"

Repository: bigbluebutton/bigbluebutton

Length of output: 285


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"

echo "== Lines 100-140 (context) =="
awk 'NR>=100 && NR<=140 {printf "%d\t%s\n", NR, $0}' "$FILE"

echo
echo "== Search for caption_json_file usage (best-effort) =="
rg -n "caption_json_file" "$FILE" || true

echo
echo "== Search for JSON usage / requires in this file =="
rg -n "\brequire\s+['\"]json['\"]|JSON\." "$FILE" || true

echo
echo "== Search for new_caption_info construction / usage =="
rg -n "new_caption_info" "$FILE" || true

echo
echo "== Extract the exact lines 110-125 =="
awk 'NR>=110 && NR<=125 {printf "%d\t%s\n", NR, $0}' "$FILE"

Repository: bigbluebutton/bigbluebutton

Length of output: 4036


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"

echo "== Lines 1-110 =="
awk 'NR>=1 && NR<=110 {printf "%d\t%s\n", NR, $0}' "$FILE"

echo
echo "== Search for 'new_caption_info['label']' usage =="
rg -n "new_caption_info\['label'\]" "$FILE" || true

echo
echo "== Search for any sanitization/escaping of label/lang =="
rg -n "(label.*gsub|gsub.*label|escape|\\bJSON\\.generate\\b|to_json|sanitize|\\brescue\\b)" "$FILE" || true

echo
echo "== Search for building captions_info and label/lang =="
rg -n "captions_info|caption_info|kind.*|label.*|lang.*" "$FILE"

Repository: bigbluebutton/bigbluebutton

Length of output: 5918


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/rap-caption-inbox.rb"

echo "== Lines 1-110 =="
awk 'NR>=1 && NR<=110 {printf "%d\t%s\n", NR, $0}' "$FILE"

echo
echo "== Search for 'new_caption_info['label']' usage =="
rg -n "new_caption_info\['label'\]" "$FILE" || true

echo
echo "== Search for sanitization/escaping of label/lang =="
rg -n "(gsub.*(label|lang)|\\bescape\\b|to_json|JSON\\.generate|sanitize)" "$FILE" || true

echo
echo "== Search for building captions_info and label/lang =="
rg -n "captions_info|caption_info|kind.*|label.*|lang.*|json_filename|JSON\\.parse" "$FILE"

Repository: bigbluebutton/bigbluebutton

Length of output: 6134


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Repo root assumed
echo "== Search for require 'json' across recordandplayback lib =="
rg -n "require\s+['\"]json['\"]" record-and-playback/core/lib record-and-playback/core lib record-and-playback -S || true

echo
echo "== Search for where JSON is required in imported lib/recordandplayback =="
FILE1="record-and-playback/core/lib/recordandplayback.rb"
if [ -f "$FILE1" ]; then
  awk 'NR>=1 && NR<=200 {printf "%d\t%s\n", NR, $0}' "$FILE1"
fi

echo
echo "== Search for label generation/constraints for new_caption_info['label'] =="
# Look for "label" and "temp_filename" near caption index creation.
rg -n "temp_filename|captions.json|localeName|localeName|captions.*inbox|rap-caption-inbox" record-and-playback -S || true

echo
echo "== Search for JSON.generate usage across repo (context for style) =="
rg -n "JSON\.generate\(" -S . || true

Repository: bigbluebutton/bigbluebutton

Length of output: 12616


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for '*-track.json' producers =="
rg -n "\*\-track\.json|track\.json|temp_filename|record_id.*track|kind.*track" record-and-playback -S

echo
echo "== Search for JSON objects with keys record_id/label/lang/temp_filename/kind =="
rg -n "['\"]record_id['\"]\s*=>\s*|['\"]label['\"]\s*=>\s*|['\"]lang['\"]\s*=>\s*|['\"]temp_filename['\"]\s*=>\s*|['\"]kind['\"]\s*=>" record-and-playback -S

echo
echo "== Search for writes to captions inbox directory =="
rg -n "captions.*inbox|caption.*inbox|inbox.*captions" record-and-playback -S

Repository: bigbluebutton/bigbluebutton

Length of output: 50384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== rap-caption-inbox.rb tail around inotify/glob (160-210) =="
awk 'NR>=150 && NR<=210 {printf "%d\t%s\n", NR, $0}' record-and-playback/core/scripts/rap-caption-inbox.rb

echo
echo "== Find producers of *-track.json in Ruby (excluding minified JS) =="
rg -n --glob='*.rb' --glob='*.yml' --glob='*.yaml' --glob='*.rb.erb' --glob='*.erb' --glob='*.sh' "\*\-track\.json|track\.json" record-and-playback -S

echo
echo "== Find localeName/label construction in core scripts utils =="
rg -n --glob='*.rb' "localeName|localeName.*label|label\s*=>" record-and-playback/core/scripts/utils -S

echo
echo "== Inspect core/scripts/utils/captions.rb around captions_json write =="
awk 'NR>=1 && NR<=140 {printf "%d\t%s\n", NR, $0}' record-and-playback/core/scripts/utils/captions.rb | sed -n '45,110p'

Repository: bigbluebutton/bigbluebutton

Length of output: 3761


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="record-and-playback/core/scripts/utils/gen_webvtt"

echo "== File exists? =="
ls -l "$FILE"

echo
echo "== Search for localeName assignment/usage =="
rg -n "localeName" "$FILE" -S

echo
echo "== Context around first localeName usage (best-effort) =="
# Print a few surrounding ranges where localeName appears
# (Use sed with line numbers based on rg output, but keep simple: dump likely areas.)
awk 'NR>=280 && NR<=380 {printf "%d\t%s\n", NR, $0}' "$FILE"

echo
echo "== Context around captions.json write (line ~430-470 from earlier search) =="
awk 'NR>=400 && NR<=520 {printf "%d\t%s\n", NR, $0}' "$FILE"

Repository: bigbluebutton/bigbluebutton

Length of output: 6274


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Narrow search to likely generators (exclude minified/vendor JS noise)
rg -n --glob='*.rb' --glob='*.py' --glob='*.erb' --glob='*.sh' --glob='*.yml' --glob='*.yaml' --glob='*.json' \
  '\*\-track\.json|-\s*track\.json|\-track\.json' record-and-playback/core -S || true

echo
echo "== Search for temp_filename / record_id / label keys in non-minified code =="
rg -n --glob='*.rb' --glob='*.py' --glob='*.erb' --glob='*.sh' --glob='*.yml' --glob='*.yaml' --glob='*.json' \
  "temp_filename|record_id|['\"]label['\"]|localeName|captions.*inbox" record-and-playback -S || true

echo
echo "== Search for writing files into captions inbox directory =="
rg -n --glob='*.rb' --glob='*.py' --glob='*.sh' --glob='*.erb' \
  "captions.*inbox.*File\.write|captions.*inbox.*File\.open|captions.*inbox.*write|*-track\.json" record-and-playback -S || true

Repository: bigbluebutton/bigbluebutton

Length of output: 4221


Use a JSON encoder when writing captions.json (avoid interpolated JSON string)

new_caption_info['label'] / new_caption_info['lang'] are inserted into a raw JSON string without escaping, so quotes/backslashes/control characters would make the resulting captions.json invalid.

Suggested fix
-      File.open(caption_json_file, 'w') do |file|
-        file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]"
-      end
+      caption_payload = [{
+        localeName: new_caption_info['label'],
+        locale: new_caption_info['lang']
+      }]
+      File.write(caption_json_file, JSON.generate(caption_payload))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
File.open(caption_json_file, 'w') do |file|
file.puts "[{\"localeName\": \"#{new_caption_info['label']}\", \"locale\": \"#{new_caption_info['lang']}\"}]"
end
caption_payload = [{
localeName: new_caption_info['label'],
locale: new_caption_info['lang']
}]
File.write(caption_json_file, JSON.generate(caption_payload))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/core/scripts/rap-caption-inbox.rb` around lines 117 -
119, Replace the interpolated JSON string with a proper JSON encoder: require
'json' if not present, build a Ruby array/hash using new_caption_info (e.g. [{
"localeName" => new_caption_info["label"], "locale" => new_caption_info["lang"]
}]) and call JSON.generate (or .to_json) when writing to caption_json_file
inside the File.open block so values are escaped correctly instead of using
file.puts with an interpolated string.

@defnull
defnull force-pushed the defnull-rap-cleanup branch from 8f69dea to 14c2f40 Compare May 21, 2026 23:33

@coderabbitai coderabbitai Bot left a comment

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.

♻️ Duplicate comments (1)
record-and-playback/screenshare/scripts/publish/screenshare.rb (1)

40-41: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

screenshare.yml loading is now incompatible with format[:extension] access

Line 40-41 switched to YAML::safe_load, but this path still expects symbol-keyed formats entries (format[:extension] on Line 72). That can fail during load (Psych::DisallowedClass) or break key lookup, causing publish-time copy failures.

Proposed minimal fix
-props = YAML::safe_load(File.read(File.expand_path('../../bigbluebutton.yml', __FILE__)))
-screenshare_props = YAML::safe_load(File.read(File.expand_path('../../screenshare.yml', __FILE__)))
+props = YAML.safe_load(File.read(File.expand_path('../../bigbluebutton.yml', __FILE__)))
+screenshare_props = YAML.safe_load(
+  File.read(File.expand_path('../../screenshare.yml', __FILE__)),
+  permitted_classes: [Symbol]
+)
#!/bin/bash
set -euo pipefail

YML="record-and-playback/screenshare/scripts/screenshare.yml"

echo "== Verify default safe_load behavior =="
ruby -ryaml -e '
content = File.read(ARGV[0])
begin
  y = YAML.safe_load(content)
  f0 = y["formats"]&.first
  puts "safe_load succeeded"
  puts "first format keys: #{f0&.keys.inspect}"
  puts "format[:extension] => #{f0&.[](:extension).inspect}"
rescue => e
  puts "#{e.class}: #{e.message}"
  exit 2
end
' "$YML"

echo "== Verify with Symbol permitted =="
ruby -ryaml -e '
content = File.read(ARGV[0])
y = YAML.safe_load(content, permitted_classes: [Symbol])
f0 = y["formats"].first
puts "first format keys: #{f0.keys.inspect}"
puts "format[:extension] => #{f0[:extension].inspect}"
' "$YML"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/screenshare/scripts/publish/screenshare.rb` around lines
40 - 41, The YAML loading of screenshare_props uses YAML::safe_load which by
default yields string keys and disallows Symbol objects, breaking later
symbol-key access like format[:extension]; update the load call for
screenshare_props to call YAML::safe_load with options to restore symbol-key
behavior (e.g., permitted_classes: [Symbol] and symbolize_names: true) so that
later code referencing format[:extension] and other symbol keys continues to
work, keeping the variable name screenshare_props and the same callers intact.
🧹 Nitpick comments (1)
record-and-playback/podcast/scripts/process/podcast.rb (1)

42-42: ⚡ Quick win

Remove unused podcast_props load at Line 42 (or wire it into behavior).

Right now it adds an unnecessary parse/read path with no effect.

Proposed fix
-podcast_props = YAML::safe_load(File.read('podcast.yml'))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/podcast/scripts/process/podcast.rb` at line 42, The
variable podcast_props is assigned from
YAML::safe_load(File.read('podcast.yml')) but never used; either remove that
line or wire podcast_props into relevant behavior (e.g., pass it into the method
that builds podcast metadata or replace hardcoded values with podcast_props).
Locate the assignment to podcast_props in podcast.rb (the
YAML::safe_load/File.read call) and either delete it or update the surrounding
code to consume podcast_props where podcast metadata/config is needed (e.g., use
podcast_props instead of hardcoded config or pass it into the processing
function).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@record-and-playback/screenshare/scripts/publish/screenshare.rb`:
- Around line 40-41: The YAML loading of screenshare_props uses YAML::safe_load
which by default yields string keys and disallows Symbol objects, breaking later
symbol-key access like format[:extension]; update the load call for
screenshare_props to call YAML::safe_load with options to restore symbol-key
behavior (e.g., permitted_classes: [Symbol] and symbolize_names: true) so that
later code referencing format[:extension] and other symbol keys continues to
work, keeping the variable name screenshare_props and the same callers intact.

---

Nitpick comments:
In `@record-and-playback/podcast/scripts/process/podcast.rb`:
- Line 42: The variable podcast_props is assigned from
YAML::safe_load(File.read('podcast.yml')) but never used; either remove that
line or wire podcast_props into relevant behavior (e.g., pass it into the method
that builds podcast metadata or replace hardcoded values with podcast_props).
Locate the assignment to podcast_props in podcast.rb (the
YAML::safe_load/File.read call) and either delete it or update the surrounding
code to consume podcast_props where podcast metadata/config is needed (e.g., use
podcast_props instead of hardcoded config or pass it into the processing
function).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f6fce3fc-b65b-45b4-ab58-c6131aa1816a

📥 Commits

Reviewing files that changed from the base of the PR and between 8f69dea and 14c2f40.

📒 Files selected for processing (17)
  • record-and-playback/core/lib/recordandplayback.rb
  • record-and-playback/core/lib/recordandplayback/events_archiver.rb
  • record-and-playback/core/scripts/bbb-0.9-beta-recording-update
  • record-and-playback/core/scripts/bbb-0.9-recording-size
  • record-and-playback/core/scripts/bbb-1.1-meeting-tag
  • record-and-playback/core/scripts/post_events/post_events_analytics_callback.rb
  • record-and-playback/core/scripts/rap-process-worker.rb
  • record-and-playback/core/scripts/utils/captions.rb
  • record-and-playback/notes/scripts/process/notes.rb
  • record-and-playback/notes/scripts/publish/notes.rb
  • record-and-playback/podcast/scripts/process/podcast.rb
  • record-and-playback/podcast/scripts/publish/podcast.rb
  • record-and-playback/presentation/scripts/caption/presentation
  • record-and-playback/presentation/scripts/process/presentation.rb
  • record-and-playback/presentation/scripts/publish/presentation.rb
  • record-and-playback/screenshare/scripts/process/screenshare.rb
  • record-and-playback/screenshare/scripts/publish/screenshare.rb

This is not necessary for security because we only load trusted config files, but linters and AI tools tend to complain about the 'insecure' use of YAML::load or JSON.load.

json
@defnull
defnull force-pushed the defnull-rap-cleanup branch from 14c2f40 to baaea29 Compare May 21, 2026 23:47
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
23.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@antobinary antobinary added this to the Release 3.0 milestone May 22, 2026
@antobinary antobinary mentioned this pull request Jun 2, 2026
16 of 17 tasks
@germanocaumo
germanocaumo self-requested a review June 3, 2026 17:39

@germanocaumo germanocaumo left a comment

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.

This is breaking screenshare format: screenshare.yml currently uses YAML symbols, so plain YAML.safe_load breaks with Psych::DisallowedClass, and publish/screenshare.rb also mixes string/symbol key access.
We can use permitted_classes: [Symbol] so it can work

Maybe we should document the supported YAML features for recording config/override files now that it will use safe_load.
For example, clarify whether admin overrides may use symbols, anchors/aliases, dates, etc. Symbols are already needed by legacy screenshare.yml

Also, there are a few files with some trailing/EOF whitespace, please fix

@defnull

defnull commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Wow, ruby YAML loading is a mess. Anchors/aliases are a core YAML feature and should be supported. Not sure about symbols (Ruby special case) or dates (not used anywhere AFAIK). To be backwards compatible we would need to use YAML::safe_load(..., permitted_classes: [Symbol], aliases: true).transform_keys(&:to_s) everywhere.

Should I do that, or better revert the YAML::save_load changes? Note that YAML::load will default to YAML::save_load in Ruby 3.1+, so we have to deal with broken YAMLs sooner or later.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
23.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)

299-305: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor inconsistency: this block still uses File.open/block-write instead of File.write.

Elsewhere in this same PR (e.g. line 405) the equivalent pattern was converted to File.write. For consistency, this could build the ffconcat content as a string first and use File.write.

♻️ Optional consistency refactor
-        File.open(concat_list_file, 'w') do |f|
-          f.write("ffconcat version 1.0\n")
-          segment_files.each do |segment|
-            f.write("file #{segment[:file]}\n")
-          end
-        end
+        concat_list_content = "ffconcat version 1.0\n" +
+          segment_files.map { |segment| "file #{segment[:file]}\n" }.join
+        File.write(concat_list_file, concat_list_content)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 299
- 305, The ffconcat list creation in the audio EDL flow still uses File.open
with incremental writes, while the same pattern elsewhere was switched to
File.write. Update the concat list generation in the same area that builds
concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 238-266: The ffmpeg extraction failure path in the audio remux
loop is silently dropping the source because `corrupt_audios` is updated before
`BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the
`audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed
extract_cmd case and only mark the file as corrupt after a failed extraction is
handled consistently with the other corruption checks. Use the existing
`audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow
to locate and update the logic.

---

Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 299-305: The ffconcat list creation in the audio EDL flow still
uses File.open with incremental writes, while the same pattern elsewhere was
switched to File.write. Update the concat list generation in the same area that
builds concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 596645ca-1592-4f1f-a866-f75d738e2c43

📥 Commits

Reviewing files that changed from the base of the PR and between baaea29 and 7f7ba86.

📒 Files selected for processing (1)
  • record-and-playback/core/lib/recordandplayback/edl/audio.rb

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)

299-305: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor inconsistency: this block still uses File.open/block-write instead of File.write.

Elsewhere in this same PR (e.g. line 405) the equivalent pattern was converted to File.write. For consistency, this could build the ffconcat content as a string first and use File.write.

♻️ Optional consistency refactor
-        File.open(concat_list_file, 'w') do |f|
-          f.write("ffconcat version 1.0\n")
-          segment_files.each do |segment|
-            f.write("file #{segment[:file]}\n")
-          end
-        end
+        concat_list_content = "ffconcat version 1.0\n" +
+          segment_files.map { |segment| "file #{segment[:file]}\n" }.join
+        File.write(concat_list_file, concat_list_content)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 299
- 305, The ffconcat list creation in the audio EDL flow still uses File.open
with incremental writes, while the same pattern elsewhere was switched to
File.write. Update the concat list generation in the same area that builds
concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 238-266: The ffmpeg extraction failure path in the audio remux
loop is silently dropping the source because `corrupt_audios` is updated before
`BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the
`audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed
extract_cmd case and only mark the file as corrupt after a failed extraction is
handled consistently with the other corruption checks. Use the existing
`audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow
to locate and update the logic.

---

Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 299-305: The ffconcat list creation in the audio EDL flow still
uses File.open with incremental writes, while the same pattern elsewhere was
switched to File.write. Update the concat list generation in the same area that
builds concat_list_file and iterates segment_files to assemble the full ffconcat
content string first, then write it once with File.write for consistency with
the newer pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 596645ca-1592-4f1f-a866-f75d738e2c43

📥 Commits

Reviewing files that changed from the base of the PR and between baaea29 and 7f7ba86.

📒 Files selected for processing (1)
  • record-and-playback/core/lib/recordandplayback/edl/audio.rb
🛑 Comments failed to post (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)

238-266: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Silent audio drop on ffmpeg extraction failure — missing warning log.

filename is added to corrupt_audios before the extract command runs (line 242), so if exec_ret fails (line 246), the audio+video source is dropped from the output entirely with no log message — unlike the sibling corruption paths at lines 224-227 and 250-252, which both warn. This makes lost audio hard to diagnose in production.

🩹 Proposed fix
           exitstatus = BigBlueButton.exec_ret(*extract_cmd)
-          next if exitstatus != 0
+          if exitstatus != 0
+            BigBlueButton.logger.warn("    Failed to extract audio from #{filename}, exit code #{exitstatus}. It will be removed from the output.")
+            next
+          end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        audio_video_files.each do |filename, info|
          next if corrupt_audios.include?(filename)

          BigBlueButton.logger.info("Extracting audio from #{filename}")
          corrupt_audios << filename
          out_filename = "#{process_dir}/#{File.basename(filename, '.*')}-audio.mkv"
          extract_cmd = [*FFMPEG, '-copyts', '-i', filename, '-map', '0:a:0', '-c', 'copy', '-f', 'matroska', out_filename]
          exitstatus = BigBlueButton.exec_ret(*extract_cmd)
          if exitstatus != 0
            BigBlueButton.logger.warn("    Failed to extract audio from #{filename}, exit code #{exitstatus}. It will be removed from the output.")
            next
          end

          new_info = audio_info(out_filename)
          new_info[:original_duration] = info[:original_duration] if info.include?(:original_duration)
          if !new_info[:audio] || !new_info[:duration]
            BigBlueButton.logger.warn('    This audio file is corrupt! It will be removed from the output.')
            next
          else
            BigBlueButton.logger.debug("    format: #{new_info[:format][:format_name]}, codec: #{new_info[:audio][:codec_name]}")
            BigBlueButton.logger.debug("    sample rate: #{new_info[:sample_rate]}, duration: #{new_info[:duration]}")
            audioinfo[out_filename] = new_info
          end

          # Update all the EDL entries to point at the new remuxed file
          edl.each do |event|
            audio = event[:audios]&.find { |a| a[:filename] == filename }
            next unless audio

            audio[:filename] = out_filename
          end
        end
🧰 Tools
🪛 RuboCop (1.88.0)

[convention] 254-254: Line is too long. [129/128]

(Layout/LineLength)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 238
- 266, The ffmpeg extraction failure path in the audio remux loop is silently
dropping the source because `corrupt_audios` is updated before
`BigBlueButton.exec_ret`, but there is no warning when `exitstatus != 0`. In the
`audio_video_files.each` block, add a `BigBlueButton.logger.warn` for the failed
extract_cmd case and only mark the file as corrupt after a failed extraction is
handled consistently with the other corruption checks. Use the existing
`audio_video_files.each`, `extract_cmd`, `exitstatus`, and `corrupt_audios` flow
to locate and update the logic.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

✅ Automated tests have passed!

@germanocaumo

Copy link
Copy Markdown
Contributor

Wow, ruby YAML loading is a mess. Anchors/aliases are a core YAML feature and should be supported. Not sure about symbols (Ruby special case) or dates (not used anywhere AFAIK). To be backwards compatible we would need to use YAML::safe_load(..., permitted_classes: [Symbol], aliases: true).transform_keys(&:to_s) everywhere.

Should I do that, or better revert the YAML::save_load changes? Note that YAML::load will default to YAML::save_load in Ruby 3.1+, so we have to deal with broken YAMLs sooner or later.

@defnull I would recommend:
adding a shared helper in record-and-playback/core/lib/boot.rb:

require 'date'
require 'yaml'

module BigBlueButton
  YAML_PERMITTED_CLASSES = [Symbol, Date, Time].freeze

  def self.load_yaml(path, fallback: {})
    YAML.safe_load_file(path, permitted_classes: YAML_PERMITTED_CLASSES, aliases: true) || fallback
  end
end

add date and time to also be defensive to other types that could be in the override file

then replacing all safe_load call sites to the helper

@antobinary

Copy link
Copy Markdown
Member

Closed via #25952 in BBB 4.0. Thank you!

@antobinary antobinary closed this Oct 15, 2026
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.

3 participants