github: Invalid GQL Query in `buildAssociatedPRsQuery` when commits/shas empty

During the upgrade to v10.0.7 which introduced GraphQL to the success lifecycle method, we’ve noticed an increase in errors in our CI pipeline and have narrowed it down to an invalid GQL Query in buildAssociatedPRsQuery as a result of the shas variable being empty (context.commits).

This may be specific to our workflow with an additional plugin, however we have the ability to force semantic release to publish a new version, which results in context.commits being empty and therefore a GQL query gets generated as below:

#graphql
query getAssociatedPRs($owner: String!, $repo: String!) {
      repository(owner: $owner, name: $repo) {
      }
 }

Resulting in:

11:56:33 GraphqlResponseError: Request failed due to following response errors:
11:56:33  - Parse error on "}" (RCURLY) at [5, 7]

It would be nice if the changes made in be394cfb9190b9cb8961e7a9155f39eb00cbde8b would handle empty context.commits as per the previous implementation.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (9 by maintainers)

Most upvoted comments

It would be nice if the changes made in be394cf would handle empty context.commits as per the previous implementation.

@babblebey can you please have a look?

i agree that successComment: false likely makes sense to avoid even searching for related issues/prs, so if we overlooked that with the change, i think it makes sense to resolve that. @babblebey does this sound likely, based on the change that was made?

I think this is already handled, we didn’t overlook for sure, In the cases where the successComment: false (as @AlexC stated they’ve just stated in their config), no action to search for associated PR and respective issues is performed for sure.

As seen here https://github.com/semantic-release/github/blob/master/lib%2Fsuccess.js#L57-L59

I guess the reason why this because a blocker was because the successComment is default to true hence the empty context.commit made it through.

A suggestion to address this permanently could be that we’d accompany the check with the context.commit emptiness check too 🤔

  if (successComment === false || isEmpty(context.commits) {
    //.. skipThePRs&IssueSearch
  } else {
    //..searchPRs&Issue&CommentThem
  }

I assume this should bring that backward compatibilty for @zachspar too 🤔

We are not trying to force a release, instead we’re running it after a merge to main, in order invoke a normal (and valid) release.

thanks for the additional detail. it is helpful to understand that you are running into the problem when processing commits as normal. i do think semantic-release-monorepo inspects the commits a bit differently than we normally do because it filters based on the file structure that each package is within the overall repository. i’m not super familiar with the implementation of semantic-release-monorepo, so it sounds like we’ll need to understand how those are handled that might be different in that case. it might be helpful to open an issue within the semantic-release-monorepo repository as well, since we arent the support team for that extension and there might be better insight there.

My configuration has worked for a long time with this unintended feature

based on the usage that you describe, i’m not confident yet that “unintended” necessarily applies here. that is what we are still trying to understand. it is still possible that we have a gap in our test coverage that could be improved for a supported use case.

@babblebey Of course 😃 the link is semantic-release-monorepo.

this reference is appreciated. is it possible to also link to your usage? is it a public repository too?

IMHO regardless of whether it was an unintended feature, it still was a feature of the code and a breaking change was introduced. Usually, when a breaking change is made (regardless of unintended) a major version release should have been tagged, with limited exceptions

we are very careful to mark breakages of supported features to our public interface as breaking. it is always possible that we make a mistake and need to revert a release and re-release as breaking, but we need to determine if there was actually a breakage before we know how we should proceed. i disagree that unintended features fall into this category, however. using a private api, for example, provides no guarantees that our changes will not result in a breakage.

we do not provide official support for monorepos, but we also want to enable community supported extensions, like semantic-release-monorepo to add support on top of our base. we need to understand more about the use case to determine if it is reasonable to handle such use cases.

I’m using the semantic-release-monorepo extension

this sounds potentially different than the ability to force publishing a new version. can you help us understand what is failing in your scenario if it is different?

My workflow is based around a monorepo and publishing multiple releases to GH

Is this repo public?? Kindly share a link to it if it is 🤔

@babblebey, we need to support backward compatibility of how the old feature worked when using GraphQL instead of search API. Thanks in advance people!