Stage #AP6 file not found context deadline exceeded

I’m stuck on .

404 reponse for other stages work for this stage it fails:

Here are my logs:

remote: [your_program] file not found
remote: [your_program] b'HTTP/1.1 404 Not Found\r\n\r\n'
remote: [stage-7] Failed to dump response: 'context deadline exceeded (Client.Timeout or context cancellation while reading body)'

And here’s a snippet of my code:

NOT_FOUND_404 = 'HTTP/1.1 404 Not Found'
CLRF = '\r\n'

def get_file_content(path, directory):
    if not directory:
        directory = ''
    filename = path[7:]
    print(directory, filename)
    f_path = os.path.join(directory, filename)
    if not filename or not os.path.exists(f_path):
        print('file not found')
        response = (NOT_FOUND_404 + CRLF + CRLF).encode('ASCII')
        print('file found', directory, filename)
        with open(f_path, 'rb') as f:
            content =
        res_arr = [OK_402, 'Content-Type: application/octet-stream', 'Content-Length: ' + str(len(content))]
        response = (CLRF.join(res_arr) + CLRF + CLRF).encode('ASCII') + content
    return response

Don’t know if you have already found it but you have defined CLRF = ‘\r\n’ at the beginning but used CRLF while using the variable name.

I got same error in go
did u find a solution?

I had typo while translating the code here. I have tried with/without CLRF/CRLF

Sorry for the delay in responding here folks!

We do know that the logs for the HTTP challenge can be a bit cryptic. This is because we’re using an off-the-shelf HTTP client which doesn’t emit friendly error messages where there’s a protocol-level error (like a missing colon, or inverted CRLF etc.).

We’re going to fix this by shipping our own parser with friendly errors soon (we did this for Redis recently and it was super helpful).

So I had the same issue when I got to this stage. I added the Content-Type and Content-Length headers (respectively set to application/octet-stream and 0) and the tests passed.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Note: I’ve updated the title of this post to include the stage ID (#AP6). You can learn about the stages rename here: Upcoming change: Stages overhaul