Audit log API returns 500 when called with an Organisation API key

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

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

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

評価

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

調査の方向性

Start with audit/views.py, especially get_queryset at the line named in the server log, and trace how it filters audit records for dashboard users and API key users. Reproduce the request with an Organisation API key and check whether the endpoint returns the project audit log or an intentional 403 instead of a 500.

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

説明

Version: self-hosted 2.295.2 (flagsmith/flagsmith:2.295.2, Docker Compose)

What happens

GET /api/v1/audit/?project=<id> returns HTTP 500 when authenticated with an Organisation API key (Authorization: Api-Key …). The same request works for a logged-in dashboard user.

Steps to reproduce
curl -i -H "Authorization: Api-Key $ORG_API_KEY" "http://localhost:8000/api/v1/audit/?project=1"
Server log
File "/app/audit/views.py", line 63, in get_queryset
TypeError: Field 'id' expected a number but got <api_keys.user.APIKeyUser object at 0x…>.
Expected

The audit log for the project (or a 403 if API keys aren't meant to read it), not a 500.

Notes

It looks like get_queryset filters on request.user as if it were an FFAdminUser; with an API key it is an APIKeyUser. Found while building FlagLens, a VS Code extension for self-hosted Flagsmith; it currently falls back to its own change journal.

主要言語
Python
スター
9.9k
フォーク
658
平均マージ
1日 15時間
マージ済み PR(30日)
168

環境構築

はじめの一歩

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

Flagsmith/flagsmith のほかの issue

Flagsmith/flagsmith の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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