Skip to content

Limit size of simulation log file to prevent BSON size error - #840

Merged
nllong merged 5 commits into
developfrom
limit-size-of-sdp-log
Jul 1, 2026
Merged

Limit size of simulation log file to prevent BSON size error#840
nllong merged 5 commits into
developfrom
limit-size-of-sdp-log

Conversation

@nllong

@nllong nllong commented Jun 30, 2026

Copy link
Copy Markdown
Member

An error shows up with large simulation logs that BSON record is >16MB. This PR will truncate the log and make a note to download the file instead of saving it in the database. The failure was silent and causes the analysis to not finish. This should improve the robustness.

Copilot AI 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.

Pull request overview

This PR aims to prevent MongoDB BSON document size failures (>16MB) by truncating the datapoint simulation log that is stored inline in DataPoint#sdp_log_file, and directing users to download the full log artifact instead. This improves robustness by avoiding silent failures that can prevent analyses from completing.

Changes:

  • Introduces byte/line limits for inline sdp_log_file content.
  • Replaces direct File.read(...).lines usage with a helper (inline_log_lines) that reads only the tail of large logs.
  • Adds a user-facing truncation notice when logs are truncated (per the new helper behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/app/jobs/dj_jobs/run_simulate_data_point.rb Outdated
Comment thread server/app/jobs/dj_jobs/run_simulate_data_point.rb Outdated
Comment thread server/app/jobs/dj_jobs/run_simulate_data_point.rb
end
end

def inline_log_lines(log_path)

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.

Addressed in commit 0de42cf by adding focused specs for inline_log_lines covering both oversized log truncation and line-cap truncation, including assertions for the user-facing truncation note.

nllong and others added 3 commits June 30, 2026 14:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@nllong
nllong merged commit 5554f4a into develop Jul 1, 2026
9 checks passed
@nllong
nllong deleted the limit-size-of-sdp-log branch July 1, 2026 14:34
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.

4 participants