Skip to content

Add Auth sheet validation for empty/whitespace-only fields#34

Merged
Shinoryo merged 4 commits into
mainfrom
copilot/enhance-auth-sheet-validation
Jan 4, 2026
Merged

Add Auth sheet validation for empty/whitespace-only fields#34
Shinoryo merged 4 commits into
mainfrom
copilot/enhance-auth-sheet-validation

Conversation

Copilot AI commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Prevents authentication failures by validating required Auth sheet fields before processing. Previously, empty or whitespace-only values in CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, or CODE_VERIFIER would cause cryptic OAuth errors downstream.

Changes

  • Added isBlank() utility: Validates string fields, handling empty strings, whitespace, null, and undefined values
  • Validation in generateAuthUrl(): Checks CLIENT_ID and REDIRECT_URI before generating auth URL
  • Validation in doGet(): Checks CLIENT_ID, CLIENT_SECRET, CODE_VERIFIER, and REDIRECT_URI before token exchange
  • New error constant MSG_AUTH_FIELD_EMPTY: Provides consistent field-specific error messages
  • Updated README.md: Added new error message to the message list

Example

// Before: OAuth fails with cryptic Microsoft API error
// After: Clear error at validation point
if (isBlank(clientId)) {
    throw new Error("Client IDが空またはスペースのみです。正しい値を入力してください。");
}

Validation occurs before any external API calls, providing immediate feedback when Auth sheet configuration is incomplete.

Original prompt

This section details on the original issue you should resolve

<issue_title>[機能要望] Authシートのバリデーションを強化したい</issue_title>
<issue_description>## 概要
Authシートのバリデーションを強化したいです。</issue_description>

Comments on the Issue (you are @copilot in this section)

@Shinoryo ## 認証URL生成処理 CELL_CLIENT_ID、CELL_REDIRECT_URIの値が空文字列・空白のみである場合、認証URL生成せず、エラーとする。

doGet時

CELL_CLIENT_ID、CELL_CLIENT_SECRET、CELL_CODE_VERIFIER、CELL_REDIRECT_URIが空文字列・空白のみである場合、トークン取得せず、エラーとする。</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 4, 2026 18:03
Co-authored-by: Shinoryo <78910349+Shinoryo@users.noreply.github.com>
Co-authored-by: Shinoryo <78910349+Shinoryo@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance validation for auth sheet Add Auth sheet validation for empty/whitespace-only fields Jan 4, 2026
Copilot AI requested a review from Shinoryo January 4, 2026 18:08
@Shinoryo Shinoryo marked this pull request as ready for review January 4, 2026 18:08
Comment thread MicrosoftToDoImporter.gs Outdated
Comment thread MicrosoftToDoImporter.gs Outdated
Comment thread MicrosoftToDoImporter.gs
Comment thread MicrosoftToDoImporter.gs Outdated
…README

Co-authored-by: Shinoryo <78910349+Shinoryo@users.noreply.github.com>

@Shinoryo Shinoryo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

確認しました。

Copilot AI left a comment

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.

Pull request overview

This PR adds validation for authentication sheet fields to prevent OAuth failures caused by empty or whitespace-only values. The changes provide early feedback when configuration is incomplete, replacing cryptic downstream API errors with clear, actionable messages.

Key Changes:

  • Added isBlank() utility function to validate string fields for empty, whitespace-only, null, or undefined values
  • Implemented validation in generateAuthUrl() for CLIENT_ID and REDIRECT_URI before auth URL generation
  • Implemented validation in doGet() for CLIENT_ID, CLIENT_SECRET, CODE_VERIFIER, and REDIRECT_URI before token exchange
  • Added MSG_AUTH_FIELD_EMPTY constant for consistent field-specific error messages

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
MicrosoftToDoImporter.gs Added isBlank() utility function, validation logic in generateAuthUrl() and doGet(), and MSG_AUTH_FIELD_EMPTY constant
README.md Added documentation for the new error message (line 166) describing when validation errors occur

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MicrosoftToDoImporter.gs
@Shinoryo Shinoryo merged commit 799be84 into main Jan 4, 2026
8 checks passed
@Shinoryo Shinoryo deleted the copilot/enhance-auth-sheet-validation branch January 4, 2026 18:27
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.

[機能要望] Authシートのバリデーションを強化したい

3 participants