Skip to content

Add File Preview Support to HostFile Entity#1912

Merged
hulto merged 3 commits intomainfrom
update-hostfile-preview-14321818820613450316
Feb 26, 2026
Merged

Add File Preview Support to HostFile Entity#1912
hulto merged 3 commits intomainfrom
update-hostfile-preview-14321818820613450316

Conversation

@hulto
Copy link
Collaborator

@hulto hulto commented Feb 25, 2026

This change adds support for file previews to the HostFile entity. The server now automatically detects if a reported file is a text file (using UTF-8 validation) or an image (using magic numbers).

For text files, the first 512KB of content is stored as a preview. For images, the full content is stored as a preview only if the file size is less than 512KB. Otherwise, no preview is stored.

The new fields are exposed via GraphQL, with a custom resolver that ensures text previews are returned as strings and image previews are returned as Base64-encoded strings.

New tests were added to tavern/internal/c2/api_report_file_test.go to verify the detection logic and preview constraints.


PR created automatically by Jules for task 14321818820613450316 started by @hulto

- Updated HostFile ent schema to include `preview` and `preview_type` fields.
- Implemented server-side file type detection (text vs image) in the ReportFile gRPC endpoint.
- Added logic to cap text previews at 512KB and image previews at <512KB.
- Exposed preview fields via GraphQL with a custom resolver for Base64/String encoding.
- Added comprehensive tests covering various file types and size constraints.

Co-authored-by: hulto <7121375+hulto@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2676    ±0 2676    ±0 0    ±0 0    ±0 0    ±0 0    ±0 1ms    ±0

Previous Results

Build 🏗️ Result 🧪 Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
#1285 2676 2676 0 0 0 0 44.0s

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2676 0 0 5.7s

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
TestDockerExecutor_Build_ContextCancellation 1 5.7s 5.7s
eldritch-libsys: std::dll_inject_impl::tests::test_dll_inject_simple 1 5.1s 5.1s
TestInteractiveShell 1 5.1s 5.1s
TestOtherStreamOutput 1 5.0s 5.0s
imix::bin/imix: install::tests::test_install_execution 3 1.6s 4.7s
imix::bin/imix: install::tests::test_install_execution 3 1.6s 4.7s
imix::bin/imix: install::tests::test_install_execution 3 1.6s 4.7s
imix::bin/imix: tests::task_tests::test_task_eprint_behavior 3 3.0s 3.0s
imix::bin/imix: tests::task_tests::test_task_eprint_behavior 3 3.0s 3.0s
imix::bin/imix: tests::task_tests::test_task_eprint_behavior 3 3.0s 3.0s

🎉 No failed tests in this run. | 🍂 No flaky tests in this run.

Github Test Reporter by CTRF 💚

🔄 This comment has been updated

@hulto hulto enabled auto-merge February 26, 2026 04:43
Comment("The type of preview available for the file"),
field.Bytes("preview").
Optional().
SchemaType(map[string]string{
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We can probably use Longtext here since the max size is in kb

@hulto hulto added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit 2ad1f84 Feb 26, 2026
10 checks passed
@hulto hulto deleted the update-hostfile-preview-14321818820613450316 branch February 26, 2026 05:56
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