스프링 - Google OAuth2 value too long for type character varying(255) 문제 해결

2025. 4. 27. 23:51· Trouble Shooting
목차
  1. 발생한 문제
  2. 원인
  3. 해결 방법
  4. 기존 social_accounts 테이블
  5. social_accounts 테이블 수정

스프링 - Google OAuth2 value too long for type character varying(255) 문제 해결

 

작성 일자 : 2025년 04월 27일


 

 

 

발생한 문제

 

서비스 운영 도중 유저분께서 구글 로그인을 시도하였으나, Unauthorized 에러가 발생했다는 제보를 받았습니다.

 

해당 시간에 로그를 확인해보니 아래와 같은 에러가 발생했습니다.

2025-04-26T08:57:32.195Z ERROR 1 --- [lumo] [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: value too long for type character varying(255)
org.springframework.dao.DataIntegrityViolationException: could not execute statement [ERROR: value too long for type character varying(255)] [update social_accounts set created_at=?,deleted_at=?,email=?,social_display_name=?,social_profile_image_url=?,social_provider=?,social_provider_id=?,updated_at=? where id=?]; SQL [update social_accounts set created_at=?,deleted_at=?,email=?,social_display_name=?,social_profile_image_url=?,social_provider=?,social_provider_id=?,updated_at=? where id=?]
Caused by: org.hibernate.exception.DataException: could not execute statement [ERROR: value too long for type character varying(255)] [update social_accounts set created_at=?,deleted_at=?,email=?,social_display_name=?,social_profile_image_url=?,social_provider=?,social_provider_id=?,updated_at=? where id=?]
Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(255)

 


 

 

원인

 

해당 에러는 구글 로그인 시도 시, social_profile_image_url의 길이가 255를 초과하여 발생한 문제입니다. 구글 로그인 시, 구글에서 제공하는 프로필 이미지 URL이 255자를 초과하여 DB에 저장할 수 없었던 것입니다.

 

일반적으로 공개용 프로필 이미지 URL은 일반적으로 90 ~ 93자 정도로 훨씬 짧습니다. 하지만, 내부 공개 URL은 1027~1030자로 훨씬 더 길어질 수도 있습니다.

 


 

 

해결 방법

 

해결 방법은 간단합니다. DB의 social_profile_image_url 컬럼의 길이를 늘려주면 됩니다.

 


 

기존 social_accounts 테이블

create table social_accounts
(
    created_at timestamp(6),
    deleted_at timestamp(6),
    id bigint not null,
    updated_at timestamp(6),
    email varchar(255) not null,
    social_display_name varchar(255),
    social_profile_image_url varchar(255),
    social_provider varchar(255) not null,
    social_provider_id varchar(255) not null,
    primary key (id),
    constraint fkxxxxxxxxxxxxxxxxxxxxxxx
        foreign key (id) references users,
    constraint social_accounts_social_provider_check
        check ((social_provider)::text = ANY (ARRAY[('GOOGLE'::character varying)::text, ('NAVER'::character varying)::text, ('KAKAO'::character varying)::text, ('DISCORD'::character varying)::text, ('NONE'::character varying)::text]))
);

 


 

social_accounts 테이블 수정

alter table social_accounts
alter column social_profile_image_url type text;

 

저작자표시 (새창열림)
  1. 발생한 문제
  2. 원인
  3. 해결 방법
  4. 기존 social_accounts 테이블
  5. social_accounts 테이블 수정
'Trouble Shooting' 카테고리의 다른 글
  • 스프링 - NICE 본인인증 API connection timed out 해결
  • Claude API 요청 시, "messages.0.cache_control: Extra inputs are not permitted" 에러
  • GithubActions에서 CloudFlare WAF ByPass하기
  • 스프링 - Google OAuth2 로그인 redirect_uri_mismatch
gerrymandering
gerrymandering
gerrymandering
gerrymandering
gerrymandering
전체
오늘
어제
  • 분류 전체보기 (83)
    • SOLID 원칙 (6)
    • 번역 (4)
    • Nginx (1)
    • Tailwind CSS (1)
    • AWS (7)
      • DMS를 사용한 RDS to OpenSearch .. (3)
      • ECS를 이용한 Blue-Green 무중단 배포 .. (7)
    • NextJS (7)
    • 기타 (12)
    • Prompt Engineering (6)
    • 읽어볼만한 글 (3)
      • 기술 (0)
      • 쓸만한 툴 (0)
      • 아이템 (0)
      • 웹 디자인 (0)
      • 기타 (3)
    • Cloud Architecture (4)
    • Trouble Shooting (9)
    • Spring (11)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

최근 댓글

최근 글

글쓰기 / 관리자
hELLO · Designed By 정상우.v4.2.1
gerrymandering
스프링 - Google OAuth2 value too long for type character varying(255) 문제 해결
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.