Skip to content

fix(qgs): Enable auto-recovery from transient network errors - #482

Open
Leechael wants to merge 1 commit into
intel:mainfrom
Leechael:fix/qgsd-context-recovery-on-network-error
Open

Leechael wants to merge 1 commit into
intel:mainfrom
Leechael:fix/qgsd-context-recovery-on-network-error

Conversation

@Leechael

@Leechael Leechael commented Dec 22, 2025 •

Copy link
Copy Markdown

Fix QGS daemon's inability to auto-recover from temporary network errors (e.g., PCCS returning unexpected HTTP status codes or connection timeouts).

Related issue: #450

When QPL fails to retrieve PCK certificates (e.g., HTTP 404 from PCCS),
the QGS context was not being released, causing all subsequent quote
requests to fail until the service was restarted.

This fix ensures context is released on failure at all critical points:

qgs_ql_logic.cpp:
- Release context when tee_att_init_quote fails (first request)
- Release context when tee_att_get_quote_size/get_quote fails
  (subsequent requests with existing context)

network_wrapper.cpp (Linux & Windows):
- Add error logging for HTTP 404 (no cache data) with full URL
- Add error logging for unexpected HTTP status codes

The root cause was that HTTP 404 errors from PCCS (indicating no
certificate data available) left the context in a corrupted state.
With this fix, the next request will automatically re-initialize
the context and retry.
@Leechael
Leechael force-pushed the fix/qgsd-context-recovery-on-network-error branch from 2a7c69f to 96d3811 Compare December 25, 2025 16:33
@bgotowal
bgotowal requested a lite review from Copilot September 11, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Recovery cleanup does not cover all network-backed request paths.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Improves QGS recovery from transient PCCS/network failures and adds HTTP diagnostics.

Changes:

  • Reset thread-local QGS contexts after quote failures.
  • Add PCCS failure logging on Windows and Linux.
  • Refine Linux HTTP error handling.
File summaries
File Description
QuoteGeneration/quote_wrapper/qgs/qgs_ql_logic.cpp Adds context cleanup after failures.
QuoteGeneration/qcnl/win/network_wrapper.cpp Logs PCCS HTTP failures on Windows.
QuoteGeneration/qcnl/linux/network_wrapper.cpp Logs PCCS HTTP failures on Linux.
Review details

Suppressed comments (1)

QuoteGeneration/qcnl/win/network_wrapper.cpp:98

  • pccs_status_code is a DWORD (an unsigned long on Windows), but this format string uses %ld, which asks qcnl_log/vsnprintf to read a long from the variadic arguments. Use the unsigned format used for dwStatus below to avoid a format/type mismatch in the new diagnostic.
        qcnl_log(SGX_QL_LOG_ERROR, "[QCNL] PCCS returned unexpected HTTP status: %ld\n", pccs_status_code);
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +200 to +201
if (resp_error_code != QGS_MSG_SUCCESS) {
ptr.reset();

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants