Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

unleash: Create dereferences a nil response when bifrost returns any non-201

オープン
#498 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
go, graphql
領域
api, backend

調査の方向性

internal/unleash/queries.go の Create から始め、次に internal/unleash/models.go の bifrostUnleashToK8s と toUnleashInstance を調べます。409 と 500 のレスポンスのカバレッジを追加し、201 以外のレスポンスがエラーを返すこと、409 を区別できること、nil の変換で panic が発生しないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

Summary

unleash.Create never checks bifrost's HTTP status. The generated client returns err only for transport failures, so any non-201 response leaves resp.JSON201 nil, and the nil flows into toUnleashInstance, which dereferences it.

Severity: low today, rising — see "Why this has not bitten yet"
Component: internal/unleash/queries.go (Create), internal/unleash/models.go:221 and the toUnleashInstance below it

Mechanism

resp, err := client.CreateInstance(ctx, req)
if err != nil {
    return nil, err          // transport errors only
}
unleashInstance := bifrostUnleashToK8s(resp.JSON201)   // nil for any non-201
…
return toUnleashInstance(unleashInstance), nil          // dereferences u.Spec

bifrostUnleashToK8s guards nil and returns nil (models.go:222-224), but toUnleashInstance starts with for _, env := range u.Spec.ExtraEnvVars with no guard.

Reachable bifrost responses today: 400 validation_failed, 400 no_version_source, 500 creation_failed.

Why this has not bitten yet

Loki, 14 days of bifrost traffic: 2985 GET /v1/releasechannels, 15 PUT /v1/unleash/{name}, and zero POST /v1/unleash. Instance creation is essentially never exercised, so the path has not been hit. No matching panic appears in nais-api's logs over the same window.

Why it is worth fixing now

nais/bifrost#549 adds two new create responses — 409 already_exists when the instance already exists, and 503 when the existence check is inconclusive. The 409 in particular is raised on a duplicate POST, which is the one non-exotic way to hit a non-201. It converts a rare data-loss path in bifrost into a nil dereference here.

Proposed fix

Check the status before converting, and map bifrost's error responses to sensible GraphQL errors — at minimum 409 should surface as "an Unleash instance already exists for this team" rather than an internal error. A nil guard in toUnleashInstance is worth having regardless, as defence in depth.

Acceptance criteria

  • A non-201 from bifrost returns an error, not a nil dereference.
  • 409 surfaces a distinguishable "already exists" message.
  • toUnleashInstance tolerates nil.
  • Test covering at least the 409 and 500 responses.
主要言語
Go
スター
3
フォーク
2
平均マージ
17時間 37分
マージ済み PR(30日)
31

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nais/api のほかの issue

nais/api の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。