Skip to content

[BUG] Fix get_flow_run_log_content 400 error when log file is in creation #4014

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 30, 2025

Problem

When running pf.runs.create_or_update() from the PromptFlow SDK and immediately trying to access logs through functions that call get_flow_run_log_content, users sometimes encounter a 400 error with the message "Value cannot be null. (Parameter 'bytes')". This happens when the log file for the run is still in the process of being created, causing the first access attempt to fail.

Solution

Added a retry mechanism specifically for this scenario in the _get_log method of RunOperations. The implementation:

  1. Adds a specialized retry decorator around the get_flow_run_log_content call
  2. Only retries on 400 errors that contain the specific error message "Value cannot be null. (Parameter 'bytes')"
  3. Uses exponential backoff starting at 1 second, doubling each time
  4. Makes up to 5 retry attempts before giving up
  5. Logs a warning message during retries to inform the user
  6. Maintains original behavior for any other types of errors

Example usage pattern that now works correctly

from promptflow.azure import PFClient

# Connect to workspace
pf = PFClient(workspace=ws)

# Create a new run
run = pf.runs.create_or_update(...)

# Immediately stream logs - previously would fail with 400 error
# Now retries until log file is created
pf.stream(run)

With this change, users no longer need to wait or add manual delays before accessing logs for newly created runs.

Fixes #4002.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] [BUG] get_flow_run_log_content returns 400 when log file for run is in creation [BUG] Fix get_flow_run_log_content 400 error when log file is in creation May 30, 2025
@Copilot Copilot AI requested a review from nagkumar91 May 30, 2025 14:28
Copilot finished work on behalf of nagkumar91 May 30, 2025 14:28
Copy link

Hi, thank you for your interest in helping to improve the prompt flow experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment.

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue/pull request label Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-recent-activity There has been no recent activity on this issue/pull request promptflow-azure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] get_flow_run_log_content returns 400 when log file for run is in creation
2 participants