Skip to content

Conversation

@Mikuto0831
Copy link
Contributor

やったこと\n- サービス作成を行うロジックの追加\n- 認証認可を使用した作成できるユーザの絞込

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 18 comments.

Comments suppressed due to low confidence (4)

backend/app/services/circle.py:2

  • Import of 'UUID' is not used.
from uuid import UUID

backend/app/core/security.py:2

  • Import of 'asyncio' is not used.
import asyncio

backend/app/core/security.py:3

  • Import of 'json' is not used.
import json

backend/app/core/security.py:4

  • Import of 'lru_cache' is not used.
from functools import lru_cache

Comment on lines +64 to +67
try:
user_info = await get_current_user(authorization)
except HTTPException as e:
raise e
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The try-except block that re-raises the same HTTPException is redundant. The exception will automatically propagate without this wrapper. Consider removing this unnecessary error handling or adding meaningful additional handling if needed.

Suggested change
try:
user_info = await get_current_user(authorization)
except HTTPException as e:
raise e
user_info = await get_current_user(authorization)

Copilot uses AI. Check for mistakes.
is_published=False,
)
session.add(new_circle)
await session.flush() # ID を生成するため flush (commit ではなく)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The comment "ID を生成するため flush (commit ではなく)" is helpful, but consider expanding it to explain why flush is preferred over commit here (e.g., "トランザクション全体をコミットせずに ID を生成するため flush を使用").

Suggested change
await session.flush() # ID を生成するため flush (commit ではなく)
await session.flush() # トランザクション全体をコミットせずに ID を生成するため flush を使用(この後に他の操作もまとめてコミットするため)

Copilot uses AI. Check for mistakes.
@@ -1,9 +1,12 @@
"""Circle service layer."""
from uuid import UUID
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The UUID import from the uuid module is not used in this file. The UUID type is used from type hints but is imported from elsewhere. This unused import should be removed.

Suggested change
from uuid import UUID

Copilot uses AI. Check for mistakes.

# テスト用データベースURL (環境変数で上書き可能)
import os
# .env ファイルを読み込む(プロジェクトルートから探す)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The .env file loading logic looks for the file in the backend directory. However, the root-level .env.example file (which was added in this PR) suggests there's also a project root .env file. Consider documenting which .env file takes precedence, or consolidating the configuration to avoid confusion about which environment file should be used for tests.

Suggested change
# .env ファイルを読み込む(プロジェクトルートから探す)
# .env ファイルの読み込みについて
# このテスト設定では、プロジェクトルート(backend ディレクトリの1つ上)の .env ファイルを読み込みます。
# バックエンド本体の .env 読み込みロジックが backend ディレクトリ内の .env を参照している場合、
# テストと本番で異なる .env ファイルが使われる可能性があります。
# どちらの .env ファイルが優先されるか、または .env ファイルの場所を統一することを推奨します。

Copilot uses AI. Check for mistakes.
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres:5432/circleportal
KC_DB_USERNAME: circleportal
KC_DB_PASSWORD: circleportal
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The Keycloak admin credentials (admin/admin) are hardcoded in the docker-compose file. While this is acceptable for development, consider adding a comment warning that these credentials should never be used in production and should be changed immediately after initial setup, even in development environments with external access.

Suggested change
KC_DB_PASSWORD: circleportal
KC_DB_PASSWORD: circleportal
# 注意: 以下の管理者アカウント(admin/admin)は開発用途の初期値です。
# 本番環境では絶対に使用しないでください。
# また、外部からアクセス可能な開発環境の場合は、初期セットアップ後すぐに変更してください。

Copilot uses AI. Check for mistakes.

このテストは、実際の Keycloak から取得したトークンを使用してエンドポイントの認可を検証します。

### 7. 開発サーバーの起動
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Following the correction of section numbering, this section should be renumbered from 7 to 8 to maintain proper sequential ordering.

Suggested change
### 7. 開発サーバーの起動
### 8. 開発サーバーの起動

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +27
class Config:
"""Pydantic config."""

json_schema_extra = {
"example": {
"name": "LinuxClub",
"campus_id": 1,
"category": "culture",
"leader_email": "[email protected]",
}
}
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The Pydantic Config class using json_schema_extra is the older Pydantic v2 style. While this still works, consider using model_config = ConfigDict(...) with the newer Pydantic v2 syntax for consistency with modern best practices. The same applies to other Config classes in this file.

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +3
import asyncio
import json
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The asyncio and json imports are not used anywhere in this file. These unused imports should be removed.

Suggested change
import asyncio
import json

Copilot uses AI. Check for mistakes.
token,
public_key,
algorithms=["RS256"],
options={"verify_aud": False}, # audience 検証はスキップ (オプション)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The JWT verification has disabled audience verification with verify_aud: False. While this is marked as optional with a comment, skipping audience verification can be a security risk if the token is intended for a different service. Consider enabling audience verification and validating against the expected client_id, or document why this is intentionally disabled for your use case.

Suggested change
options={"verify_aud": False}, # audience 検証はスキップ (オプション)
audience=settings.keycloak_client_id, # audience 検証を有効化

Copilot uses AI. Check for mistakes.
import httpx
from fastapi import HTTPException, status
from jose import JWTError, jwt, jwk
from jose.exceptions import JWTClaimsError
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Import of 'JWTClaimsError' is not used.

Suggested change
from jose.exceptions import JWTClaimsError

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants