Skip to content

WithDiagnostics(Diagnostics{}) warns only about cartesian joins: zero RepeatLimit and Budget mean off #356

Backlog

Description

@borderss

ant.WithDiagnostics(ant.Diagnostics{}) looks like it turns diagnostics on, but with the zero config only the cartesian-join warning works. RepeatLimit 0 and Budget 0 both mean off (diagnostics.go, over and repeated), so an N+1 loop inside ant.Watch stays silent. Someone has to know to pick a number before the most useful warning appears.

This is for the owner to decide, so it is filed rather than fixed. One option: when RepeatLimit is 0, use a small default such as 10, and take a negative value to turn it off. Budget could stay off by default, since a time budget depends on the app.

Either way, the Diagnostics doc comment could say what the zero value does.

Activity

  1. added
    enhancement
    area: tooling
    area: dx
    on Nov 28, 2026
  2. lx3133584 commented on Nov 28, 2026

    @lx3133584
    Contributor

    Claiming this one, and since it moves a default, the plan first.

    What the zero value does now. over in diagnostics.go:93 needs Budget > 0 and repeated at :94 needs RepeatLimit > 0, so WithDiagnostics(Diagnostics{}) is Alert with nothing of its own to say. The one warning that still arrives is the cartesian one, because it reads the query rather than the scope. That is the shape the issue points at: the option reads as "turn it on" and leaves out the warning most people need.

    A default for RepeatLimit. 0 means 10, and a negative value means off, so RepeatLimit: -1 still has an escape hatch and nothing forces a budget-sized number on an app. Budget stays off at 0: how long a request may spend depends on the app, and 10ms would fire in the wrong places.

    The sentinel negative is worth one line in the doc comment, not a second field: the field has no place to put "off" that 0 has not already taken as "on". The alternative is a pointer, which reads worse at every call site for one value.

    Where the 10 lives. An unexported defaultRepeatLimit = 10 next to the struct, and repeated reads limit := d.config.RepeatLimit; if limit == 0 { limit = defaultRepeatLimit } before the comparison. The alert message takes limit, so it says 10 and not 0.

    The doc comments on the type and on RepeatLimit say what the zero value means, and WithDiagnostics says it turns every warning on unless one is set off.

    Tests in tests/features/developer_tooling/diagnostics_test.go: the zero config for RepeatLimit warns on the 11th run of one statement and not the 10th, RepeatLimit: -1 stays silent, and the existing RepeatLimit: 3 case keeps its number in the message.

    Docs. docs/ROADMAP.md:547 keeps its line; nothing else names the field. If an ADR is wanted for the default it is 177 onward, and #347 has 177.

    The other read of the issue is docs only, without touching the default, which leaves the silent N+1 loop in place. Say if you would rather have that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: dxarea: toolingenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions