Skip to content

plugin/forward: Forward NODATA responses to Next handler#8065

Merged
yongtang merged 3 commits into
coredns:masterfrom
AliveDevil:alternate-24
May 27, 2026
Merged

plugin/forward: Forward NODATA responses to Next handler#8065
yongtang merged 3 commits into
coredns:masterfrom
AliveDevil:alternate-24

Conversation

@AliveDevil

@AliveDevil AliveDevil commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

1. Why is this pull request needed and what does it do?

Forward can't handle NODATA-responses, which are technically error responses as well.
Using the NOERROR-case to allow forwarding to Next handler, when upstream returned NODATA.
Unfortunately, NODATA isn't a real rcode, but inferred from the answer section, the plugin code has been updated to inspect NODATA-answers as well.

2. Which issues (if any) are related?

See coredns/alternate#24 - original PR coredns/alternate#48.
Altered the original PR to not include the magic string "NODATA", with a "-1" RCode value.

3. Which documentation changes (if any) need to be made?

See changes to plugin/forward/README.md, added new config option "next_on_nodata", which activates the new behavior.

4. Does this introduce a backward incompatible change or deprecation?

After discussion a new backwards-compatible change was introduced.

Details Current behavior for: ``` forward . a.b.c.d { next NOERROR } forward . d.e.f.0 ``` would _always_ respond with the response from `d.e.f.0`. The new behavior only uses `d.e.f.0` when `a.b.c.d` returned `NOERROR` with an empty answer set. In some sense it is a backward incompatible change, but I'd argue that this case is rather exotic, forwarding and discarding the answer would be quite wasteful.

I've built this locally, and verified it works just like my previous patch to the alternate-plugin, which has been running here for two years unchanged.

Signed-off-by: AliveDevil <AliveDevil@users.noreply.github.com>
@yongtang

Copy link
Copy Markdown
Member

@AliveDevil Thanks for the contribution and sorry for the delay! Wondering if having an option to selectively control this behavior will make it backward compatible. Also, wondering if having a simple test will help coverage?

@AliveDevil

Copy link
Copy Markdown
Contributor Author

Hi @yongtang, thanks for getting back to this :)
I'm not opposed to adding a separate confguration key noerror_is_nodata, which toggles the new behavior to continue only when nodata is received on noerror:

forward 1.2.3.4 {
  noerror_is_nodata
  next noerror
}

retaining the current behavior when unspecified, continuing with any noerror upstream response:

forward 1.2.3.4 {
  next noerror
}

or adding a separate behavior switch next_nodata (or next_on_nodata) to be used independently of next noerror.

forward 1.2.3.4 {
  next …
  next_nodata
# or
  next_on_nodata
}

Any preferred option here?

For a unit test: I can look into providing one.

@yongtang

Copy link
Copy Markdown
Member

@AliveDevil Thanks! I feel next_on_nodata might be easier, as its an extension with better backward compatibility?

Instead of hijacking `NOERROR`

Signed-off-by: AliveDevil <AliveDevil@users.noreply.github.com>
Signed-off-by: AliveDevil <AliveDevil@users.noreply.github.com>
@AliveDevil

Copy link
Copy Markdown
Contributor Author

Updated opening description, added tests.
New option "next_on_nodata" introduced.

@yongtang yongtang merged commit eb49f40 into coredns:master May 27, 2026
13 checks passed
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