Skip to content

Conversation

tbrand
Copy link
Contributor

@tbrand tbrand commented Aug 8, 2025

Description of Changes

Checklist

  • Modified relevant documentation
  • Verified operation in local environment
  • Executed npm run cdk:test and if there are snapshot differences, execute npm run cdk:test:update-snapshot to update snapshots

Related Issues

@tbrand tbrand added the major Changes equivalent to a major version increment label Aug 8, 2025
@tbrand tbrand changed the title v5.0.0 v5.0.0 (not automated) Aug 12, 2025
tbrand and others added 5 commits August 12, 2025 10:40
Co-authored-by: Taichiro Suzuki <taichirs@amazon.co.jp>
Co-authored-by: Taichiro Suzuki <taichirs@amazon.co.jp>
Co-authored-by: Taichiro Suzuki <taichirs@amazon.co.jp>
maekawataiki and others added 3 commits August 18, 2025 12:44
Co-authored-by: Yusuke Wada <52243855+wadabee@users.noreply.github.com>
Co-authored-by: remote-swe-app[bot] <123456+remote-swe-app[bot]@users.noreply.github.com>
Co-authored-by: Yusuke Wada <wadaysk@amazon.co.jp>
Co-authored-by: sugi <sugi.mount@gmail.com>
Co-authored-by: sugusugi <sugusugi@amazon.co.jp>
Co-authored-by: kaye <33077429+kaye-dev@users.noreply.github.com>
Co-authored-by: Taichiro Suzuki <taichirs@amazon.co.jp>
finally:
clean_ws_directory()

return StreamingResponse(generate(), media_type="text/event-stream")

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI 6 days ago

To fix this issue, we should ensure that whenever an exception is caught and reported to the end-user (in any streamed or regular response), the error message reveals no sensitive information. We should log the actual exception and stack trace on the server, but only emit a generic message in the events streamed to the user.

Specifically, in AgentManager.process_request_streaming (in src/agent.py), replace the event:

"message": f"An error occurred while processing your request: {str(e)}"

with:

"message": "An internal server error occurred while processing your request."

and log the exception stack trace internally for diagnosis.

You may want to use logger.exception to record the stack trace.

Files/regions/lines to change:

  • Only src/agent.py needs updating, specifically the exception handler in process_request_streaming.

Implementation Needed:

  • Update the error message as described.
  • Replace the logger call to output the stacktrace (logger.error(...)logger.exception(...)).

Suggested changeset 1
packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py b/packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py
--- a/packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py
+++ b/packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py
@@ -73,11 +73,11 @@
                     yield json.dumps(event, ensure_ascii=False) + "\n"
 
         except Exception as e:
-            logger.error(f"Error processing agent request: {e}")
+            logger.exception("Error processing agent request")
             error_event = {
                 "event": {
                     "internalServerException": {
-                        "message": f"An error occurred while processing your request: {str(e)}",
+                        "message": "An internal server error occurred while processing your request.",
                     }
                 }
             }
EOF
@@ -73,11 +73,11 @@
yield json.dumps(event, ensure_ascii=False) + "\n"

except Exception as e:
logger.error(f"Error processing agent request: {e}")
logger.exception("Error processing agent request")
error_event = {
"event": {
"internalServerException": {
"message": f"An error occurred while processing your request: {str(e)}",
"message": "An internal server error occurred while processing your request.",
}
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
except Exception as e:
logger.error(f"Error processing request: {e}")
logger.error(traceback.format_exc())
return create_error_response(str(e))

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI 6 days ago

To fix this problem, error messages sent to the user should be generic and not include details directly derived from the exception, while the full details and stack trace can still be logged on the server for investigative purposes. Specifically, in app.py, replace create_error_response(str(e)) with something like create_error_response("An internal error has occurred while processing your request."). Leave the extensive info in logs as in the current logger statements.
Only app.py requires editing: specifically, the except Exception as e: block in the /invocations endpoint where the response to the client is constructed.
No additional imports or helper functions are needed because a generic string can be used directly.


Suggested changeset 1
packages/cdk/lambda-python/generic-agent-core-runtime/app.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/cdk/lambda-python/generic-agent-core-runtime/app.py b/packages/cdk/lambda-python/generic-agent-core-runtime/app.py
--- a/packages/cdk/lambda-python/generic-agent-core-runtime/app.py
+++ b/packages/cdk/lambda-python/generic-agent-core-runtime/app.py
@@ -85,7 +85,7 @@
     except Exception as e:
         logger.error(f"Error processing request: {e}")
         logger.error(traceback.format_exc())
-        return create_error_response(str(e))
+        return create_error_response("An internal error has occurred while processing your request.")
     finally:
         clean_ws_directory()
 
EOF
@@ -85,7 +85,7 @@
except Exception as e:
logger.error(f"Error processing request: {e}")
logger.error(traceback.format_exc())
return create_error_response(str(e))
return create_error_response("An internal error has occurred while processing your request.")
finally:
clean_ws_directory()

Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Collaborator

@kazuhitogo kazuhitogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release!

@kazuhitogo kazuhitogo marked this pull request as ready for review August 26, 2025 00:36
@kazuhitogo kazuhitogo merged commit 5cf8050 into main Aug 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major Changes equivalent to a major version increment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants