-
Notifications
You must be signed in to change notification settings - Fork 279
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
$status var in responses #6225
$status var in responses #6225
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ impl RequestInputs { | |
&self, | ||
config: Option<&CustomConfiguration>, | ||
context: Option<Map<ByteString, Value>>, | ||
status: Option<u16>, | ||
) -> IndexMap<String, Value> { | ||
let mut map = IndexMap::with_capacity_and_hasher(3, Default::default()); | ||
map.insert("$args".to_string(), Value::Object(self.args.clone())); | ||
|
@@ -43,6 +44,9 @@ impl RequestInputs { | |
if let Some(config) = config { | ||
map.insert("$config".to_string(), json!(config)); | ||
} | ||
if let Some(status) = status { | ||
map.insert("$status".to_string(), Value::Number(status.into())); | ||
} | ||
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's interesting, but i think it's better to have an we should probably also validate which variables are available in the different selections. i'll make a ticket for that. |
||
map | ||
} | ||
} | ||
|
@@ -127,7 +131,7 @@ fn request_params_to_requests( | |
&connector.transport, | ||
response_key | ||
.inputs() | ||
.merge(connector.config.as_ref(), Some(context.clone())), | ||
.merge(connector.config.as_ref(), Some(context.clone()), None), | ||
original_request, | ||
debug, | ||
)?; | ||
|
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.
The fact that
KnownVariable::Status
maps toNone
here points to something missing here. We're reusing theVariable
andVariableType
definitions from the URL template code, which doesn't seem right, and doesn't capture a key distinction, which is request vs response variables - status only makes sense in a response context. We've already had bugs here, where$context
was passed in where it wasn't supported. I'd like to see some better type definitions around variables which clarify where they can be used and prevent mistakes where a variable is passed in somewhere it isn't supported at the code level, and also enable validations at the user level that they are only referencing variables where they are supported. This doesn't necessarily need to be solved in this PR, but it does come up here as it's really unclear without additional context why this one variable maps toNone
here.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.
yeah that's a good point. i'll make a ticket