Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): Accept and forward unknown envelope items #1246

Merged
merged 7 commits into from
Apr 28, 2022

Conversation

jan-auer
Copy link
Member

@jan-auer jan-auer commented Apr 27, 2022

Relay has a policy to accept and forward unknown data on near every level, from individual fields in the event protocol to entire Envelope items. However, unknown envelope item types failed envelope parsing which lead to dropping the full Envelope with all its items.

This patch introduces a new ItemType::Unknown that contains the original, case sensitive, item type. Based on a new config flag routing.accept_unknown_items, this item is either retained and forwarded without modification, or is dropped immediately after parsing the envelope. The default is false for processing Relays (to drop unknown items), and true for all other configurations.

Unknown items are treated as event-independent. This means, they are split away from an event into a separate envelope. This is the most likely case for future event payloads. As with all other feature updates, customers and users are still recommended to update Relay when adopting new major features on their clients.

Alongside this change, empty envelopes no longer cause a 400 Bad Request response. Most importantly, this allows clients to send envelopes containing all new items without receiving an error. As a side effect, this effectively makes sending empty envelopes legal in the ingestion API. To diagnose SDK bugs in the future, we can start to add internal diagnostics.

See also:

@jan-auer
Copy link
Member Author

In Point of Presence Relays, the new configuration flag should be set to false.

/// By default, items of this type are forwarded without modification. Processing Relays and
/// Relays explicitly configured to do so will instead drop those items. This allows
/// forward-compatibility with new item types where we expect outdated Relays.
Unknown(String),
Copy link
Member Author

@jan-auer jan-auer Apr 27, 2022

Choose a reason for hiding this comment

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

Note to reviewers: A major part of this diff is caused by dropping Copy as a result of using a String here, and it makes using ItemType rather unergonomic.

In practice, our item types are supposed to be really short. mem::size_of::<String>() == 24, which means without size penalty, we could allocate a short static string here, instead, to restore Copy.

Copy link
Member

Choose a reason for hiding this comment

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

I would do that within this PR but up to you

@jan-auer jan-auer marked this pull request as ready for review April 28, 2022 07:48
@jan-auer jan-auer requested a review from a team April 28, 2022 07:48
* master:
  fix(metrics): Enforce metric name length limit (#1238)
Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

nice, lots of tests!

/// By default, items of this type are forwarded without modification. Processing Relays and
/// Relays explicitly configured to do so will instead drop those items. This allows
/// forward-compatibility with new item types where we expect outdated Relays.
Unknown(String),
Copy link
Member

Choose a reason for hiding this comment

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

I would do that within this PR but up to you

///
/// Defaults to `true` for all Relay modes other than processing mode. In processing mode, this
/// is disabled by default since the item cannot be handled.
unknown_items: Option<bool>,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Should we call this accept_unknown_items?

Copy link
Member Author

Choose a reason for hiding this comment

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

I originally had it as forward_unknown_items, but it seemed rather long. Subjectively, the combined key of routing.unknown_items: false is clear to me, but I'm happy to update to a more descriptive name if you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I thought the same as joris but I get the reasoning from jan as well, so i don't have an opinion on this

Copy link
Member

Choose a reason for hiding this comment

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

I thought it would make sense to make it consistent with the function name, but I did not consider the routing. prefix. With the prefix I think it's clear enough.

relay-server/src/endpoints/common.rs Show resolved Hide resolved
@jan-auer jan-auer enabled auto-merge (squash) April 28, 2022 18:03
@jan-auer jan-auer merged commit fd2219a into master Apr 28, 2022
@jan-auer jan-auer deleted the fix/accept-unknown-items branch April 28, 2022 18:12
jjbayer added a commit that referenced this pull request Nov 28, 2022
As we did in #1246 for
`ItemType`, add an `Unknown(String)` variant to `AttachmentType`. When
`accept_unknown_items` is set to false, items with this attachment type
will be dropped.

This will allow outdated external Relays to forward new attachment types
instead of dropping the entire envelope.

This defect was discovered in getsentry/rfcs#33,
which introduces a new attachment type.
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.

None yet

3 participants