-
Notifications
You must be signed in to change notification settings - Fork 11
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: added PostContext handling properties and context as nested variants #510
Conversation
…ables, and other props ending up as extra props on context
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
This is a very small change in terms of code but it's quite a large and significant change in terms of where Edge goes from this point on and how that impacts the evolution of the SDK ecosytem. I have some thoughts (oh no!).
Some suggestions though. If you're willing to tighten up the new behavior going forward without impacting the old behavior, I think we can do this: #[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PostContext {
pub context: Option<Context>,
#[serde(flatten)]
pub properties: Option<Context>,
#[serde(flatten)]
pub extra_properties: HashMap<String, String>,
}
impl From<PostContext> for Context {
fn from(input: PostContext) -> Self {
if let Some(context) = input.context {
context
} else {
IncomingContext {
context: input.properties.unwrap_or_default(),
extra_properties: input.extra_properties,
}
.into()
}
}
} This lets us maintain the existing legacy behavior and reuse that code path, while denying that same behavior where we don't need it. It's also lets us use the Rust type system a bit more effectively rather than falling back to a string map. Works with existing tests but I do think we need to cover the weird cases a bit more effectively. I'd also like to suggest renaming the Gosh, you write 10 lines and code and suddenly your colleague has 500 lines of opinions. I'm so sorry. |
No need to be sorry here. I think your suggestion makes sense. Let's have a f2f sync on this, I was struggling to come up with other cases here. My one argument is that the one client we know uses this is the proxy-client, which we promise should work with just swapping from a proxy backend to the edge backend. But I think your suggestion is less invasive than my solution. Let's see if we can get it to work? |
Ye! I'm excited! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes LGTM!
No description provided.