Skip to content

Fix nil-pointer panic in ai resolver when time_range/comparison_time_range are omitted#9703

Merged
nishantmonu51 merged 1 commit into
mainfrom
nishant/fix-ai-resolver-nil-time-range-panic
Jul 20, 2026
Merged

Fix nil-pointer panic in ai resolver when time_range/comparison_time_range are omitted#9703
nishantmonu51 merged 1 commit into
mainfrom
nishant/fix-ai-resolver-nil-time-range-panic

Conversation

@nishantmonu51

Copy link
Copy Markdown
Collaborator

Fixes a guaranteed nil-pointer panic in the ai resolver when time_range or comparison_time_range is omitted from the resolver properties.

  • ResolveInteractive unconditionally dereferences r.props.TimeRange and r.props.ComparisonTimeRange when building AnalystAgentArgs, but both are optional *metricsview.TimeRange fields left nil when absent. Since comparison_time_range is almost never set, essentially every AI report without it panicked; the panic was recovered by the controller, so the report perpetually failed with a reconcile error instead of crashing the process.
  • Fix: default both pointers to &metricsview.TimeRange{} in newAI. An empty time range is already a no-op in resolveTimeRange (its IsZero() guard), so the agent args now receive zero time.Time values, meaning "no time bounds".

Steps to reproduce (before this fix):

  1. In a Rill project with AI enabled, create a report whose data section uses the AI resolver with only a prompt, e.g. data: { ai: { agent: analyst_agent, prompt: "Summarize sales", is_report: true } } — do not set time_range or comparison_time_range.
  2. Trigger the report (via its schedule or "Run now").
  3. The report fails every time: the resource shows a reconcile error and the runtime logs contain a recovered nil-pointer panic in aiResolver.ResolveInteractive. Setting only time_range still fails on the comparison_time_range dereference.

To test: repeat the steps above on this branch; the report executes and produces an AI summary. Also verify that a report with an explicit time_range expression (e.g. expression: P7D) still resolves the range correctly.

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 July 19, 2026 07:43
@nishantmonu51

Copy link
Copy Markdown
Collaborator Author

@codex: review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 00d55dd200

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@nishantmonu51
nishantmonu51 merged commit 7fd2bf9 into main Jul 20, 2026
16 checks passed
@nishantmonu51
nishantmonu51 deleted the nishant/fix-ai-resolver-nil-time-range-panic branch July 20, 2026 05:47
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