Skip to content

Error when analyzing photos (challenge 1) #14

Description

@diale-13

Hi im not sure if im doing something wrong but when i upload any picture i get this error response. I used the terraform code twice and it got no errors on the output.

HTTP/1.1 500 INTERNAL SERVER ERROR
Server: Werkzeug/2.2.3 Python/3.7.16
Date: Sat, 27 Sep 2025 21:07:58 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 20546
Connection: close

<!doctype html>
<html lang=en>
  <head>
    <title>botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
 // Werkzeug Debugger</title>
    <link rel="stylesheet" href="?__debugger__=yes&amp;cmd=resource&amp;f=style.css">
    <link rel="shortcut icon"
        href="?__debugger__=yes&amp;cmd=resource&amp;f=console.png">
    <script src="?__debugger__=yes&amp;cmd=resource&amp;f=debugger.js"></script>
    <script>
      var CONSOLE_MODE = false,
          EVALEX = true,
          EVALEX_TRUSTED = false,
          SECRET = "az4D2SMOk7r25v4jSB0g";
    </script>
  </head>
  <body style="background-color: #fff">
    <div class="debugger">
<h1>NoSuchKey</h1>
<div class="detail">
  <p class="errormsg">botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
</p>
</div>
<h2 class="traceback">Traceback <em>(most recent call last)</em></h2>
<div class="traceback">
  <h3></h3>
  <ul><li><div class="frame" id="frame-139711985642192">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">2552</em>,
      in <code class="function">__call__</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">    </span>def __call__(self, environ: dict, start_response: t.Callable) -&gt; t.Any:</pre>
<pre class="line before"><span class="ws">        </span>&#34;&#34;&#34;The WSGI server calls the Flask application object as the</pre>
<pre class="line before"><span class="ws">        </span>WSGI application. This calls :meth:`wsgi_app`, which can be</pre>
<pre class="line before"><span class="ws">        </span>wrapped to apply middleware.</pre>
<pre class="line before"><span class="ws">        </span>&#34;&#34;&#34;</pre>
<pre class="line current"><span class="ws">        </span>return self.wsgi_app(environ, start_response)</pre></div>
</div>

<li><div class="frame" id="frame-139711985737808">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">2532</em>,
      in <code class="function">wsgi_app</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">            </span>try:</pre>
<pre class="line before"><span class="ws">                </span>ctx.push()</pre>
<pre class="line before"><span class="ws">                </span>response = self.full_dispatch_request()</pre>
<pre class="line before"><span class="ws">            </span>except Exception as e:</pre>
<pre class="line before"><span class="ws">                </span>error = e</pre>
<pre class="line current"><span class="ws">                </span>response = self.handle_exception(e)</pre>
<pre class="line after"><span class="ws">            </span>except:  # noqa: B001</pre>
<pre class="line after"><span class="ws">                </span>error = sys.exc_info()[1]</pre>
<pre class="line after"><span class="ws">                </span>raise</pre>
<pre class="line after"><span class="ws">            </span>return response(environ, start_response)</pre>
<pre class="line after"><span class="ws">        </span>finally:</pre></div>
</div>

<li><div class="frame" id="frame-139711985737936">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask_cors/extension.py"</cite>,
      line <em class="line">194</em>,
      in <code class="function">wrapped_function</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">        </span># Wrap exception handlers with cross_origin</pre>
<pre class="line before"><span class="ws">        </span># These error handlers will still respect the behavior of the route</pre>
<pre class="line before"><span class="ws">        </span>if options.get(&#39;intercept_exceptions&#39;, True):</pre>
<pre class="line before"><span class="ws">            </span>def _after_request_decorator(f):</pre>
<pre class="line before"><span class="ws">                </span>def wrapped_function(*args, **kwargs):</pre>
<pre class="line current"><span class="ws">                    </span>return cors_after_request(app.make_response(f(*args, **kwargs)))</pre>
<pre class="line after"><span class="ws">                </span>return wrapped_function</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">            </span>if hasattr(app, &#39;handle_exception&#39;):</pre>
<pre class="line after"><span class="ws">                </span>app.handle_exception = _after_request_decorator(</pre>
<pre class="line after"><span class="ws">                    </span>app.handle_exception)</pre></div>
</div>

<li><div class="frame" id="frame-139711985738192">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">2529</em>,
      in <code class="function">wsgi_app</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">        </span>ctx = self.request_context(environ)</pre>
<pre class="line before"><span class="ws">        </span>error: t.Optional[BaseException] = None</pre>
<pre class="line before"><span class="ws">        </span>try:</pre>
<pre class="line before"><span class="ws">            </span>try:</pre>
<pre class="line before"><span class="ws">                </span>ctx.push()</pre>
<pre class="line current"><span class="ws">                </span>response = self.full_dispatch_request()</pre>
<pre class="line after"><span class="ws">            </span>except Exception as e:</pre>
<pre class="line after"><span class="ws">                </span>error = e</pre>
<pre class="line after"><span class="ws">                </span>response = self.handle_exception(e)</pre>
<pre class="line after"><span class="ws">            </span>except:  # noqa: B001</pre>
<pre class="line after"><span class="ws">                </span>error = sys.exc_info()[1]</pre></div>
</div>

<li><div class="frame" id="frame-139711985738320">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">1825</em>,
      in <code class="function">full_dispatch_request</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">            </span>request_started.send(self)</pre>
<pre class="line before"><span class="ws">            </span>rv = self.preprocess_request()</pre>
<pre class="line before"><span class="ws">            </span>if rv is None:</pre>
<pre class="line before"><span class="ws">                </span>rv = self.dispatch_request()</pre>
<pre class="line before"><span class="ws">        </span>except Exception as e:</pre>
<pre class="line current"><span class="ws">            </span>rv = self.handle_user_exception(e)</pre>
<pre class="line after"><span class="ws">        </span>return self.finalize_request(rv)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">    </span>def finalize_request(</pre>
<pre class="line after"><span class="ws">        </span>self,</pre>
<pre class="line after"><span class="ws">        </span>rv: t.Union[ft.ResponseReturnValue, HTTPException],</pre></div>
</div>

<li><div class="frame" id="frame-139711985738448">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask_cors/extension.py"</cite>,
      line <em class="line">194</em>,
      in <code class="function">wrapped_function</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">        </span># Wrap exception handlers with cross_origin</pre>
<pre class="line before"><span class="ws">        </span># These error handlers will still respect the behavior of the route</pre>
<pre class="line before"><span class="ws">        </span>if options.get(&#39;intercept_exceptions&#39;, True):</pre>
<pre class="line before"><span class="ws">            </span>def _after_request_decorator(f):</pre>
<pre class="line before"><span class="ws">                </span>def wrapped_function(*args, **kwargs):</pre>
<pre class="line current"><span class="ws">                    </span>return cors_after_request(app.make_response(f(*args, **kwargs)))</pre>
<pre class="line after"><span class="ws">                </span>return wrapped_function</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">            </span>if hasattr(app, &#39;handle_exception&#39;):</pre>
<pre class="line after"><span class="ws">                </span>app.handle_exception = _after_request_decorator(</pre>
<pre class="line after"><span class="ws">                    </span>app.handle_exception)</pre></div>
</div>

<li><div class="frame" id="frame-139711985738704">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">1823</em>,
      in <code class="function">full_dispatch_request</code></h4>
  <div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws">        </span>try:</pre>
<pre class="line before"><span class="ws">            </span>request_started.send(self)</pre>
<pre class="line before"><span class="ws">            </span>rv = self.preprocess_request()</pre>
<pre class="line before"><span class="ws">            </span>if rv is None:</pre>
<pre class="line current"><span class="ws">                </span>rv = self.dispatch_request()</pre>
<pre class="line after"><span class="ws">        </span>except Exception as e:</pre>
<pre class="line after"><span class="ws">            </span>rv = self.handle_user_exception(e)</pre>
<pre class="line after"><span class="ws">        </span>return self.finalize_request(rv)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">    </span>def finalize_request(</pre></div>
</div>

<li><div class="frame" id="frame-139711985738832">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>,
      line <em class="line">1799</em>,
      in <code class="function">dispatch_request</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">            </span>and req.method == &#34;OPTIONS&#34;</pre>
<pre class="line before"><span class="ws">        </span>):</pre>
<pre class="line before"><span class="ws">            </span>return self.make_default_options_response()</pre>
<pre class="line before"><span class="ws">        </span># otherwise dispatch to the handler for that endpoint</pre>
<pre class="line before"><span class="ws">        </span>view_args: t.Dict[str, t.Any] = req.view_args  # type: ignore[assignment]</pre>
<pre class="line current"><span class="ws">        </span>return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">    </span>def full_dispatch_request(self) -&gt; Response:</pre>
<pre class="line after"><span class="ws">        </span>&#34;&#34;&#34;Dispatches the request and on top of that performs request</pre>
<pre class="line after"><span class="ws">        </span>pre and postprocessing as well as HTTP exception catching and</pre>
<pre class="line after"><span class="ws">        </span>error handling.</pre></div>
</div>

<li><div class="frame" id="frame-139711985739088">
  <h4>File <cite class="filename">"/home/ec2-user/backend/app.py"</cite>,
      line <em class="line">239</em>,
      in <code class="function">product_lookup</code></h4>
  <div class="source "><pre class="line before"><span class="ws">        </span>if command_output:</pre>
<pre class="line before"><span class="ws">            </span>return jsonify({&#39;metadata_output&#39;: command_output}), 400</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws">        </span>features_file_key = &#39;image_features.pkl&#39;  # S3 key for the features file</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line current"><span class="ws">        </span>response = s3.get_object(Bucket=bucket_name, Key=features_file_key)</pre>
<pre class="line after"><span class="ws">        </span>features = pickle.loads(response[&#39;Body&#39;].read())</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">        </span>payload = {</pre>
<pre class="line after"><span class="ws">            </span>&#39;bucket_name&#39;: bucket_name,</pre>
<pre class="line after"><span class="ws">            </span>&#39;img_key&#39;: photo_filename</pre></div>
</div>

<li><div class="frame" id="frame-139711985739472">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/botocore/client.py"</cite>,
      line <em class="line">553</em>,
      in <code class="function">_api_call</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">            </span>if args:</pre>
<pre class="line before"><span class="ws">                </span>raise TypeError(</pre>
<pre class="line before"><span class="ws">                    </span>f&#34;{py_operation_name}() only accepts keyword arguments.&#34;</pre>
<pre class="line before"><span class="ws">                </span>)</pre>
<pre class="line before"><span class="ws">            </span># The &#34;self&#34; in this scope is referring to the BaseClient.</pre>
<pre class="line current"><span class="ws">            </span>return self._make_api_call(operation_name, kwargs)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">        </span>_api_call.__name__ = str(py_operation_name)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">        </span># Add the docstring to the client method</pre>
<pre class="line after"><span class="ws">        </span>operation_model = service_model.operation_model(operation_name)</pre></div>
</div>

<li><div class="frame" id="frame-139711985739600">
  <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/botocore/client.py"</cite>,
      line <em class="line">1009</em>,
      in <code class="function">_make_api_call</code></h4>
  <div class="source library"><pre class="line before"><span class="ws">            </span>error_info = parsed_response.get(&#34;Error&#34;, {})</pre>
<pre class="line before"><span class="ws">            </span>error_code = error_info.get(&#34;QueryErrorCode&#34;) or error_info.get(</pre>
<pre class="line before"><span class="ws">                </span>&#34;Code&#34;</pre>
<pre class="line before"><span class="ws">            </span>)</pre>
<pre class="line before"><span class="ws">            </span>error_class = self.exceptions.from_code(error_code)</pre>
<pre class="line current"><span class="ws">            </span>raise error_class(parsed_response, operation_name)</pre>
<pre class="line after"><span class="ws">        </span>else:</pre>
<pre class="line after"><span class="ws">            </span>return parsed_response</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws">    </span>def _make_request(self, operation_model, request_dict, request_context):</pre>
<pre class="line after"><span class="ws">        </span>try:</pre></div>
</div>
</ul>
  <blockquote>botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
</blockquote>
</div>

<div class="plain">
    <p>
      This is the Copy/Paste friendly version of the traceback.
    </p>
    <textarea cols="50" rows="10" name="code" readonly>Traceback (most recent call last):
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 2552, in __call__
    return self.wsgi_app(environ, start_response)
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 2532, in wsgi_app
    response = self.handle_exception(e)
  File &#34;/usr/local/lib/python3.7/site-packages/flask_cors/extension.py&#34;, line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File &#34;/usr/local/lib/python3.7/site-packages/flask_cors/extension.py&#34;, line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File &#34;/usr/local/lib/python3.7/site-packages/flask/app.py&#34;, line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File &#34;/home/ec2-user/backend/app.py&#34;, line 239, in product_lookup
    response = s3.get_object(Bucket=bucket_name, Key=features_file_key)
  File &#34;/usr/local/lib/python3.7/site-packages/botocore/client.py&#34;, line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File &#34;/usr/local/lib/python3.7/site-packages/botocore/client.py&#34;, line 1009, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
</textarea>
</div>
<div class="explanation">
  The debugger caught an exception in your WSGI application.  You can now
  look at the traceback which led to the error.  <span class="nojavascript">
  If you enable JavaScript you can also use additional features such as code
  execution (if the evalex feature is enabled), automatic pasting of the
  exceptions and much more.</span>
</div>
      <div class="footer">
        Brought to you by <strong class="arthur">DON'T PANIC</strong>, your
        friendly Werkzeug powered traceback interpreter.
      </div>
    </div>

    <div class="pin-prompt">
      <div class="inner">
        <h3>Console Locked</h3>
        <p>
          The console is locked and needs to be unlocked by entering the PIN.
          You can find the PIN printed out on the standard output of your
          shell that runs the server.
        <form>
          <p>PIN:
            <input type=text name=pin size=14>
            <input type=submit name=btn value="Confirm Pin">
        </form>
      </div>
    </div>
  </body>
</html>

<!--

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2552, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2532, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/ec2-user/backend/app.py", line 239, in product_lookup
    response = s3.get_object(Bucket=bucket_name, Key=features_file_key)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 1009, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.

-->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions