Skip to content

feat: Add Issue Dependencies API support#4130

Open
tommaso-moro wants to merge 7 commits intogoogle:masterfrom
tommaso-moro:tommy/issue-dependencies-support
Open

feat: Add Issue Dependencies API support#4130
tommaso-moro wants to merge 7 commits intogoogle:masterfrom
tommaso-moro:tommy/issue-dependencies-support

Conversation

@tommaso-moro
Copy link
Copy Markdown

@tommaso-moro tommaso-moro commented Apr 2, 2026

closes: #4129

Add Issue Dependencies API support

Add support for the Issue Dependencies REST API.

Changes

New file github/issues_dependencies.go adds four methods to IssuesService:

Method Endpoint Description
ListBlockedBy GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by List dependencies blocking an issue
AddBlockedBy POST /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by Add a blocking dependency
RemoveBlockedBy DELETE /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by/{issue_id} Remove a blocking dependency
ListBlocking GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking List issues this issue is blocking

Also adds IssueDependencyRequest type used by AddBlockedBy.

Testing

Full test coverage in github/issues_dependencies_test.go (12 tests) using standard helpers: testBadOptions, testNewRequestAndDoFailure, testURLParseError, testJSONMarshal.

Auto-generated files updated via go generate: accessors, accessor tests, iterators, and iterator tests.

All scripts pass: script/fmt.sh, script/test.sh, script/lint.sh.

Add four new methods to IssuesService for the Issue
Dependencies REST API (apiVersion 2026-03-10):

- ListBlockedBy: list dependencies blocking an issue
- AddBlockedBy: add a blocking dependency to an issue
- RemoveBlockedBy: remove a blocking dependency
- ListBlocking: list issues that an issue is blocking

Includes IssueDependencyRequest type, full test coverage
with testBadOptions, testNewRequestAndDoFailure,
testURLParseError, and testJSONMarshal helpers.
Run go generate to add:
- GetIssueID accessor for IssueDependencyRequest
- ListBlockedBy and ListBlocking iterators with tests
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 2, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (96a3651) to head (14b279b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4130      +/-   ##
==========================================
+ Coverage   93.74%   93.76%   +0.02%     
==========================================
  Files         211      212       +1     
  Lines       19685    19765      +80     
==========================================
+ Hits        18453    18533      +80     
  Misses       1034     1034              
  Partials      198      198              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tommaso-moro tommaso-moro marked this pull request as ready for review April 2, 2026 14:46
Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @tommaso-moro!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Apr 2, 2026
@tommaso-moro
Copy link
Copy Markdown
Author

@Not-Dhananjay-Mishra thank you for the review! I have addressed the points you raised and updated this branch.

IssueFieldID *int64 `json:"issue_field_id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
DataType *string `json:"data_type,omitempty"`
Value interface{} `json:"value,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be caught by a linter:

Suggested change
Value interface{} `json:"value,omitempty"`
Value any `json:"value,omitempty"`


// IssueDependencyRequest represents a request to add a dependency to an issue.
type IssueDependencyRequest struct {
IssueID *int64 `json:"issue_id"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IssueID *int64 `json:"issue_id"`
IssueID int64 `json:"issue_id"`

// GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#list-dependencies-an-issue-is-blocked-by
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by
func (s *IssuesService) ListBlockedBy(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *IssuesService) ListBlockedBy(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) {
func (s *IssuesService) ListBlockedBy(ctx context.Context, owner, repo string, issueNumber int, opts *ListOptions) ([]*Issue, *Response, error) {

because

Image

// GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#add-a-dependency-an-issue-is-blocked-by
//
//meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by
func (s *IssuesService) AddBlockedBy(ctx context.Context, owner, repo string, number int, issueDepReq IssueDependencyRequest) (*Issue, *Response, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *IssuesService) AddBlockedBy(ctx context.Context, owner, repo string, number int, issueDepReq IssueDependencyRequest) (*Issue, *Response, error) {
func (s *IssuesService) AddBlockedBy(ctx context.Context, owner, repo string, issueNumber int, issueDepReq IssueDependencyRequest) (*Issue, *Response, error) {

// GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#remove-dependency-an-issue-is-blocked-by
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by/{issue_id}
func (s *IssuesService) RemoveBlockedBy(ctx context.Context, owner, repo string, number int, issueID int64) (*Issue, *Response, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *IssuesService) RemoveBlockedBy(ctx context.Context, owner, repo string, number int, issueID int64) (*Issue, *Response, error) {
func (s *IssuesService) RemoveBlockedBy(ctx context.Context, owner, repo string, issueNumber int, issueID int64) (*Issue, *Response, error) {
Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis should we change the type of issueNumber to int64? Because both issue_id and issue_number in the spec is integer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis should we change the type of issueNumber to int64? Because both issue_id and issue_number in the spec is integer.

Yes indeed... thank you for catching that, as well as these other issues, @alexandear! I appreciate it!

// GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#list-dependencies-an-issue-is-blocking
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking
func (s *IssuesService) ListBlocking(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *IssuesService) ListBlocking(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) {
func (s *IssuesService) ListBlocking(ctx context.Context, owner, repo string, issueNumber int, opts *ListOptions) ([]*Issue, *Response, error) {

Comment on lines +70 to +76
var v IssueDependencyRequest
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))

testMethod(t, r, "POST")
if !cmp.Equal(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var v IssueDependencyRequest
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
testMethod(t, r, "POST")
if !cmp.Equal(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
testMethod(t, r, "POST")
testBody(t, r, `{"issue_id":42}` + "\n")

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

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Issue Dependencies REST API

5 participants