-
Notifications
You must be signed in to change notification settings - Fork 490
The statusDescription header must contain the status code and reason phrase, separated by a single space -- ALB returning 502 from Lambda #507
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
Comments
Hi @Kralizek, this probably isn't an issue with the .NET SDK, so I'm going to close out this issue. Please try reading some of our ALB troubleshooting documentation, asking a question on AWS Forums or Stack Overflow, or opening a Premium Support case. |
Thanks @klaytaybai For future desperate souls, you can find the same question on StackOverflow here: https://stackoverflow.com/questions/57562352/aws-alb-returning-502-from-lambda-instead-of-custom-http-status |
Also, in the documentation it's clearly state that the Here is the relevant documentation (emphasis mine): https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#respond-to-load-balancer
|
Should we change the |
That would be helpful, but where would you get the reason phrase from? I used ReasonPhrases.GetReasonPhrase(int) but I am not sure taking a dependency on Microsoft.AspNetCore.WebUtilities is worth it |
I was thinking of something like this: class Program
{
static void Main(string[] args)
{
Console.WriteLine(new ApplicationLoadBalancerResponse {StatusCode = 200 }.StatusDescription);
Console.WriteLine(new ApplicationLoadBalancerResponse { StatusCode = 404 }.StatusDescription);
Console.WriteLine(new ApplicationLoadBalancerResponse { StatusCode = 99999 }.StatusDescription);
}
}
public class ApplicationLoadBalancerResponse
{
public int StatusCode { get; set; }
string _statusDescription = null;
public string StatusDescription
{
get
{
if(this._statusDescription == null && this.StatusCode != 0)
{
var statusName = (System.Net.HttpStatusCode)this.StatusCode;
return $"{this.StatusCode} {statusName}";
}
return this._statusDescription;
}
set { this._statusDescription = value; }
}
} This results in the following:
|
That looks pretty neat! |
Also... On a sidenote, would it be possible to make the dictionary containing the headers use a case insensitive comparer? While working on converting a lambda from API Gateway to ALB, I took me a while to understand why I couldn't find the "Host" header (API Gateway), then I saw that ALB returns all headers in lower case (which is pretty peculiar, since I have always seen the headers be written in Pascal casing). |
Reopening this as a feature request. |
Thanks @Kralizek for pointing out the SO post. I just wanted to add that that in my testing with .net core lambda behind ALB, adding a space to the StatusDescription had no effect on the outcome of the 502. I had to add a header to get it to work.
|
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue. |
@ashishdhingra are issues labeled as feature request also subject to expiration? |
I've created a Lambda that check on a DynamoDB table the existence of a record matching host and request path and, if found, returns a redirect to the matching URL.
My Lambda returns this response but the ALB returns 502.
This is the log I find in CloudWatch for the Lambda function
This is the response I get
I couldn't find anything saying we can't return non-200 responses from Lambda, so I really have no idea...
The text was updated successfully, but these errors were encountered: