mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 12:25:33 +08:00
fix: Handle videos with no comments in YouTube Comments component (#10633)
* fix: Handle videos with no comments in YouTube Comments component - Define column order once to avoid code duplication - Create empty DataFrame with proper schema when no comments exist - Prevents KeyError when trying to reorder columns on empty DataFrame - Returns consistent DataFrame structure regardless of comment count * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * [autofix.ci] apply automated fixes * Update component_index.json --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com>
This commit is contained in:
@ -2481,35 +2481,19 @@
|
||||
}
|
||||
],
|
||||
"src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json": [
|
||||
{
|
||||
"type": "Hex High Entropy String",
|
||||
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json",
|
||||
"hashed_secret": "ef3435e29e3a2c5dcbbb633856c85561848cd995",
|
||||
"is_verified": false,
|
||||
"line_number": 268,
|
||||
"is_secret": false
|
||||
},
|
||||
{
|
||||
"type": "Secret Keyword",
|
||||
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json",
|
||||
"hashed_secret": "665b1e3851eefefa3fb878654292f16597d25155",
|
||||
"is_verified": false,
|
||||
"line_number": 838,
|
||||
"is_secret": false
|
||||
},
|
||||
{
|
||||
"type": "Hex High Entropy String",
|
||||
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json",
|
||||
"hashed_secret": "d6e6d7b4b115cd3b9d172623199f8c403055fecc",
|
||||
"is_verified": false,
|
||||
"line_number": 1452
|
||||
"line_number": 1291
|
||||
},
|
||||
{
|
||||
"type": "Hex High Entropy String",
|
||||
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json",
|
||||
"hashed_secret": "54ed260e3bc31bc77ee06754dff850981d39a66c",
|
||||
"is_verified": false,
|
||||
"line_number": 2223,
|
||||
"line_number": 2062,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@ -8214,5 +8198,5 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"generated_at": "2026-04-23T21:12:19Z"
|
||||
"generated_at": "2026-04-24T03:31:30Z"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -193,14 +193,7 @@ class YouTubeCommentsComponent(Component):
|
||||
else:
|
||||
request = None
|
||||
|
||||
# Convert to DataFrame
|
||||
comments_df = pd.DataFrame(comments_data)
|
||||
|
||||
# Add video metadata
|
||||
comments_df["video_id"] = video_id
|
||||
comments_df["video_url"] = self.video_url
|
||||
|
||||
# Sort columns for better organization
|
||||
# Define column order
|
||||
column_order = [
|
||||
"video_id",
|
||||
"video_url",
|
||||
@ -217,7 +210,20 @@ class YouTubeCommentsComponent(Component):
|
||||
if self.include_metrics:
|
||||
column_order.extend(["like_count", "reply_count"])
|
||||
|
||||
comments_df = comments_df[column_order]
|
||||
# Handle empty comments case
|
||||
if not comments_data:
|
||||
# Create empty DataFrame with proper columns
|
||||
comments_df = pd.DataFrame(columns=column_order)
|
||||
else:
|
||||
# Convert to DataFrame
|
||||
comments_df = pd.DataFrame(comments_data)
|
||||
|
||||
# Add video metadata
|
||||
comments_df["video_id"] = video_id
|
||||
comments_df["video_url"] = self.video_url
|
||||
|
||||
# Reorder columns
|
||||
comments_df = comments_df[column_order]
|
||||
|
||||
return DataFrame(comments_df)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user