Skip to content

feat: attach exported files to scheduled report emails with export.attach - #10031

Merged
nishantmonu51 merged 3 commits into
mainfrom
nishant/report-email-attachments
Oct 21, 2026
Merged

nishantmonu51 merged 3 commits into
mainfrom
nishant/report-email-attachments

Conversation

@nishantmonu51

Copy link
Copy Markdown
Collaborator

Adds an opt-in option to attach a scheduled report's export file to its emails.

  • New "Attach file to emails" checkbox in the explore report form, backed by export_attach on ReportOptions and ReportSpec and export.attach in report YAML. Off by default, so existing reports are unchanged.
  • Only supported for query-based (explore) reports run as the creator, and only for email: the admin API and the parser reject it for recipient mode, canvas PDF and AI reports, and Slack notifications keep the download link.
  • The reconciler exports the data once with the report owner's attributes (the same claims as the creator-mode download link) and attaches it to every email. Exports larger than 10 MB are not attached: the email says so and keeps the download link, and the run records a warning. Other export errors fail the run.
  • queries.ProtoToExportQuery is extracted from the download handler, so attachments and download links build the same query.
  • The SMTP sender only composes a multipart message when there is an attachment; all other emails are unchanged.
  • testruntime.InstanceOptions.AdminService lets runtime tests deliver reports (the no-op admin skips them); the new reconciler tests use it.
  • Reports without an owner (YAML reports without admin_owner_user_id) skip the attachment with a warning, since their download links are issued per recipient.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@nishantmonu51
nishantmonu51 requested a review from pjain1 October 17, 2026 17:33
- Add an opt-in `export.attach` report property (`export_attach` on `ReportSpec` and `ReportOptions`) and an "Attach file to emails" option in the explore report form.
- Only supported for query-based reports run as the creator; the admin API and the parser reject it for recipient mode, canvas PDF and AI reports.
- The report reconciler exports the data once with the report owner's attributes and attaches it to every email; Slack notifications keep the download link.
- Exports larger than 10 MB are not attached; the email says so and keeps the download link, and the run records a warning.
- Extract `queries.ProtoToExportQuery` from the download handler, so attachments and download links build the same query.
- The SMTP sender only composes a multipart message when there is an attachment.
- Add `testruntime.InstanceOptions.AdminService`, so runtime tests can deliver reports.
@AdityaHegde
AdityaHegde self-requested a review October 20, 2026 05:41

@AdityaHegde AdityaHegde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The include metadata and attach checkboxes have different info icon positions. We can perhaps move both to match attach's checkbox?
Image

Comment thread runtime/pkg/email/sender.go Outdated

type Sender interface {
Send(toEmail, toName, subject, body string) error
Send(toEmail, toName, subject, body string, attachments ...Attachment) error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any specific reason to use rest param instead of array? Will be easier to add new params in the future?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Switched to []Attachment; the other callers pass nil. (83f67a8)

</Tooltip>
</div>
<Checkbox
checked={$data["exportAttach"] && canAttach}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: adding canAttach to check feels weird. We should either reset exportAttach when we cannot attach or still show the selected state but disabled.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Went with the reset: exportAttach is cleared when Run as is not Creator, so the checkbox binds it directly. (83f67a8)

…ption outside creator mode, align the metadata info icon
…attachments

# Conflicts:
#	proto/gen/rill/admin/v1/api.pb.go
#	proto/gen/rill/runtime/v1/resources.pb.go
@nishantmonu51
nishantmonu51 force-pushed the nishant/report-email-attachments branch from d6e7c09 to 31c2ca0 Compare October 21, 2026 06:24
@nishantmonu51

Copy link
Copy Markdown
Collaborator Author

Info icons: Include metadata now uses the checkbox hint prop, so both match the attach one. (83f67a8)

@AdityaHegde AdityaHegde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

UI code looks good

@nishantmonu51
nishantmonu51 merged commit 6340857 into main Oct 21, 2026
24 of 25 checks passed
@nishantmonu51
nishantmonu51 deleted the nishant/report-email-attachments branch October 21, 2026 13:50
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