Skip to content

ateapi: reject unknown fields on the request, not just the resource - #1216

Merged
Tim Hockin (thockin) merged 1 commit into
agent-substrate:mainfrom
HavenXia:reject-request-unknown-fields
Aug 26, 2026
Merged

Tim Hockin (thockin) merged 1 commit into
agent-substrate:mainfrom
HavenXia:reject-request-unknown-fields

Conversation

@HavenXia

@HavenXia Haven Xia (HavenXia) commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Fix #1213, we should also reject unknown fields at request level.

Refactor all functionality back into a gRPC interceptor to check every incoming request, no need to handle every new request method.

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@thockin

Copy link
Copy Markdown
Collaborator

Needs rebase, sorry

@thockin Tim Hockin (thockin) 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.

Should we do this on EVERY incoming request? E.g. as an interceptor?

Comment thread cmd/ateapi/internal/controlapi/actor.go Outdated
var fldPath *field.Path
var errs field.ErrorList

errs = append(errs, validateNoUnknownFields(req, fldPath)...)

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 fldPath is nil - when you rebase you will find it easier to just say nil

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.

Or just skip that argument - if we validate every request, it will always start as nil.

@HavenXia
Haven Xia (HavenXia) force-pushed the reject-request-unknown-fields branch 3 times, most recently from d241e53 to 0ff1e90 Compare August 26, 2026 04:31
@HavenXia

Copy link
Copy Markdown
Member Author

Should we do this on EVERY incoming request? E.g. as an interceptor?

Refactor into an ate interceptor.

@HavenXia

Copy link
Copy Markdown
Member Author

green

// Use "request" for the root message which has no field path.
path = field.NewPath("request")
}
errs = append(errs, field.Invalid(path, field.OmitValueType{}, ""))

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.

We almost never use the last arg to "Invalid()" but this may be the exception -- should we say something like "unknown field with protobuf tag 99" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SG, added.

@thockin Tim Hockin (thockin) 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.

Small points then LGTM

@HavenXia
Haven Xia (HavenXia) force-pushed the reject-request-unknown-fields branch from 0ff1e90 to d68340b Compare August 26, 2026 17:19
@HavenXia

Copy link
Copy Markdown
Member Author

green again

@thockin
Tim Hockin (thockin) merged commit 7e33913 into agent-substrate:main Aug 26, 2026
10 of 11 checks passed
Luiz Oliveira (laoj2) pushed a commit that referenced this pull request Sep 2, 2026
An old server replica doing Read-Modify-Write should drop unknown fields
on read and serve the reduced object.

Here we add `proto.UnmarshalOptions{DiscardUnknown: true}` because when
we read an unknown field in storage layer, it must mean a newer replica
has written such a field. Since we have declined requests with unknown
fields with interceptors in #1216.


Fixes #1205

- [ ] Tests pass
- [x] Appropriate changes to documentation are included in the PR
@HavenXia
Haven Xia (HavenXia) deleted the reject-request-unknown-fields branch October 28, 2026 16:26
@HavenXia
Haven Xia (HavenXia) restored the reject-request-unknown-fields branch October 28, 2026 16:27
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.

Unknown fields in requests should be disallowed.

2 participants