Skip to content

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Dec 31, 2025

While testing the docs-builder changelog add command and attempting to pull PR information from a private repo, the command failed to fetch and did not generate a changelog even when I provided the minimal --title and --type. Better handling is required for situations where the fetch fails.

Summary

  • Updated the docs-builder changelog add command to generate a basic changelog even when PR fetch fails.
  • Added tests to verify that PR fetch failures are handled correctly

Behavior

  • When --prs is provided and PR fetch fails:
    • Generate a basic changelog file
    • Use --title and --type if provided
      • If missing, comment out title/type in the output with TODO comments
    • Emit warnings indicating manual updates are needed

Examples

docs-builder changelog add --title "test title" --type enhancement --products cloud-hosted --prs 149106 --owner elastic --repo cloud

Originally this type of command failed to create a changelog and reported this error: Error: Failed to fetch PR information from GitHub for PR: 149106. Skipping this PR.

Now the command successfully creates a changelog with this warning: Warning: Failed to fetch PR information from GitHub for PR: 149106. Generating basic changelog with provided values.

If you omit the --title option, for example, you'll get another warning like this: Warning: Title is missing. The changelog will be created with title commented out. Please manually update the title field.

Changes

  • Modified CreateSingleChangelog method:
    • When PR fetch fails, continue processing instead of returning an error
    • Track prFetchFailed to adjust validation behavior
    • Emit warnings instead of errors when title/type are missing after PR fetch failure
  • Updated CreateChangelogsForMultiplePrs method:
    • Changed error to warning when PR fetch fails
    • Continue processing to generate changelogs even when PR info cannot be fetched
  • Enhanced BuildChangelogData method:
    • Handle nullable title/type by using empty strings when null
  • Updated GenerateYaml method:
    • Added parameters to track missing title/type
    • Comment out missing fields in the YAML output with TODO comments
    • Insert commented fields at the beginning of the YAML data section
  • Fixed filename generation:
    • Handle missing title by using PR URL or "changelog" as fallback
  • Updated mock setup to handle full PR URLs (not just PR numbers)
  • Added cloud-serverless product to test configuration
  • Fixed routing so single PRs go directly to CreateSingleChangelog
  • Added blocking label check to CreateSingleChangelog for consistency

Tests

  1. CreateChangelog_WithPrOptionButPrFetchFails_WithTitleAndType_CreatesChangelog
  • When PR fetch fails but --title and --type are provided, a changelog is created using those values.
  1. CreateChangelog_WithPrOptionButPrFetchFails_WithoutTitleAndType_CreatesChangelogWithCommentedFields
  • When PR fetch fails and --title or --type are not provided, a changelog is created with commented title/type fields and warnings are emitted.
  1. CreateChangelog_WithMultiplePrsButPrFetchFails_GeneratesBasicChangelogs
  • When multiple PRs are provided and fetch fails, basic changelogs are still generated.

The tests verify that:

  • Changelogs are created even when PR fetch fails
  • Provided --title and --type values are used when available
  • Missing title/type are commented out in the YAML output
  • Appropriate warnings are emitted
  • The behavior works for both single and multiple PRs

Outstanding work

I think there is likely a need for a way to supply GitHub tokens or other credentials necessary to access private repos.

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: composer-1 agent

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants