Skip to content

librarian: if one library fails in generation, should revert changes #1682

@zhumin8

Description

@zhumin8

In generation logic, when generating all libraries, we allow failure for one library and continue:

if err := r.generateSingleLibrary(ctx, library.ID, outputDir); err != nil {
// TODO(https://github.com/googleapis/librarian/issues/983): record failure and report in PR body when applicable
slog.Error("failed to generate library", "id", library.ID, "err", err)
prBody += fmt.Sprintf("%s failed to generate\n", library.ID)

For failure that occurred in runGenerateCommand, prior to "clean and copy" this should work as we expect.

generatedLibraryID, err := r.runGenerateCommand(ctx, libraryID, outputDir)
if err != nil {
return err
}

However, if failure is in subsequent steps, e.g. in build. We should expect the code change for the failed library reverted and not included in final worktree/PR. Currently, we do not have clean ups, I believe they will end-up in the changes produced.

if err := r.runBuildCommand(ctx, generatedLibraryID); err != nil {
return err
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions