Skip to content

Conversation

@toothlessdev
Copy link
Member

@toothlessdev toothlessdev commented Aug 29, 2025

✅ Linked Issue

🔍 What I did

  • UnauthorizedException 외의 예외에 대해 동일한 리다이렉트 처리 추가

Summary by CodeRabbit

  • Bug Fixes
    • Improved redirect behavior on the notice creation page. Unauthorized users are now sent to the sign-in page, while users without required permissions are redirected to complete profile registration. All other errors also redirect to sign-in. This ensures clearer guidance and smoother recovery from access issues.

@toothlessdev toothlessdev self-assigned this Aug 29, 2025
@vercel
Copy link

vercel bot commented Aug 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
mosu-client Ready Ready Preview Comment Aug 29, 2025 1:55pm

@coderabbitai
Copy link

coderabbitai bot commented Aug 29, 2025

Walkthrough

Server-side error handling in getServerSideProps for the notice creation page was refactored to branch redirects by error type: Unauthorized redirects to /signin, Forbidden redirects to /mypage/profile/register, and all other errors redirect to /signin. No exported/public signatures changed.

Changes

Cohort / File(s) Summary
Server-side auth error handling
mosu-app/src/pages/notice/new.tsx
Refactor getServerSideProps error handling: split Unauthorized vs Forbidden vs other errors; adjust redirects accordingly. No API/signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Next.js as Next.js (SSR)
  participant GSSP as getServerSideProps
  participant Auth as Auth Service

  User->>Next.js: Request /notice/new
  Next.js->>GSSP: Invoke
  GSSP->>Auth: Validate session / permissions
  Auth-->>GSSP: Error or OK

  alt Unauthorized error
    GSSP-->>Next.js: redirect -> /signin
    Next.js-->>User: 302 /signin
  else Forbidden error
    GSSP-->>Next.js: redirect -> /mypage/profile/register
    Next.js-->>User: 302 /mypage/profile/register
  else Other error
    GSSP-->>Next.js: redirect -> /signin
    Next.js-->>User: 302 /signin
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix 500 error when unauthenticated user accesses inquiry write page (#377)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add ForbiddenException branch redirecting to /mypage/profile/register (mosu-app/src/pages/notice/new.tsx, getServerSideProps) The issue only targets unauthenticated (Unauthorized) 500 error; changing Forbidden handling to a specific profile registration redirect is not stated in #377. Line numbers not available in summary.

Suggested labels

버그 리포트, 우선순위 (상)

Suggested reviewers

  • kimgho

Poem

I hop through routes with whiskered care,
No 500s now to snare the air—
If not logged in, to signin you’ll glide,
If lacking rights, to profiles you’re guided.
Carrots cached, redirects tight,
Ship it fast, by moonlit night.
(_/)<🥕>

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix#377

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

Warnings
⚠️ PR에 Reviewers가 지정되어 있지 않습니다. 리뷰어를 지정해주세요.
Messages
📖 ✅ PR 제목에 이슈 번호가 포함되어 있습니다.
📖 ✅ PR에 라벨이 지정되어 있습니다.
📖 ✅ PR에 Assignees가 지정되어 있습니다.
📖 ✅ package.json에 변경사항이 없습니다.
📖 ✅ 브랜치 이름 'fix#377'이 컨벤션을 따릅니다.
📖 ✅ TypeScript 컴파일이 성공적으로 완료되었습니다.
📖 ✅ ESLint 검사 결과 문제가 없습니다.

📝 추가 및 변경된 파일

총 1개 파일 변경

└── 📂 mosu-app/
    └── 📂 src/
        └── 📂 pages/
            └── 📂 notice/
                └── ⚛️ new.tsx

Generated by 🚫 dangerJS against 2d155e6

@toothlessdev toothlessdev merged commit 4e59b91 into main Aug 29, 2025
6 of 7 checks passed
@toothlessdev toothlessdev deleted the fix#377 branch August 29, 2025 13:57
@github-project-automation github-project-automation bot moved this from 진행중 to 완료 in mosu-client Aug 29, 2025
@github-actions
Copy link

📚 Storybook이 Chromatic에 배포되었습니다!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
mosu-app/src/pages/notice/new.tsx (2)

32-36: Preserve and encode returnUrl (avoid hardcoded path, keep queries).

Use context.resolvedUrl to round-trip the original URL.

-            return {
-                redirect: {
-                    destination: "/auth/member/signin?returnUrl=/notice/new",
-                    permanent: false,
-                },
-            };
+            return {
+                redirect: {
+                    destination: `/auth/member/signin?returnUrl=${encodeURIComponent(
+                        context.resolvedUrl ?? "/notice/new",
+                    )}`,
+                    permanent: false,
+                },
+            };

37-38: Harden 403 detection beyond instanceof.

Ensure Forbidden redirects even if a plain/axios error is thrown.

-        } else if (error instanceof ForbiddenException) {
+        } else if (
+            error instanceof ForbiddenException ||
+            (error as any)?.status === 403 ||
+            (error as any)?.response?.status === 403
+        ) {
🧹 Nitpick comments (1)
mosu-app/src/pages/notice/new.tsx (1)

44-51: Catch-all redirect: add minimal logging and preserve returnUrl.

Logs unexpected failures server-side and keeps the original URL.

-        } else {
-            return {
-                redirect: {
-                    destination: "/auth/member/signin?returnUrl=/notice/new",
-                    permanent: false,
-                },
-            };
+        } else {
+            // Server-side log for observability (no user impact)
+            console.error("[notice/new] getServerSideProps unexpected error:", error);
+            return {
+                redirect: {
+                    destination: `/auth/member/signin?returnUrl=${encodeURIComponent(
+                        context.resolvedUrl ?? "/notice/new",
+                    )}`,
+                    permanent: false,
+                },
+            };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 13a1452 and 2d155e6.

📒 Files selected for processing (1)
  • mosu-app/src/pages/notice/new.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
mosu-app/src/pages/notice/new.tsx (1)
mosu-app/src/shared/errors/HTTPException.ts (1)
  • UnauthorizedException (74-80)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & Publish Storybook
🔇 Additional comments (1)
mosu-app/src/pages/notice/new.tsx (1)

30-51: LGTM on redirect coverage—this will prevent the 500 for unauthenticated access.

The added else ensures safe fallback instead of crashing.

Comment on lines +30 to 31
if (error instanceof UnauthorizedException) {
return {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Harden 401 detection beyond instanceof.

Cross-bundle instanceof checks can fail. Also check status codes.

-        if (error instanceof UnauthorizedException) {
+        if (
+            error instanceof UnauthorizedException ||
+            (error as any)?.status === 401 ||
+            (error as any)?.response?.status === 401
+        ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (error instanceof UnauthorizedException) {
return {
if (
error instanceof UnauthorizedException ||
(error as any)?.status === 401 ||
(error as any)?.response?.status === 401
) {
return {
// …
🤖 Prompt for AI Agents
In mosu-app/src/pages/notice/new.tsx around lines 30-31, the code only checks
error instanceof UnauthorizedException which can fail across bundles; change the
conditional to also detect a 401 by checking common status properties (e.g.
error.status === 401 || error.response?.status === 401 || error.statusCode ===
401) and keep the existing UnauthorizedException branch behavior when any of
these checks are true; ensure the combined condition is used wherever
UnauthorizedException was checked so 401 responses are reliably handled
regardless of instanceof mismatches.

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

Projects

Status: 완료

Development

Successfully merging this pull request may close these issues.

[🐞 버그 리포트] 로그인하지 않은 사용자가 문의글 쓰기 페이지 접속시 500 에러가 뜨는 현상

2 participants