SWM-15th-Dnight / flutter-client

android / ios client source code
0 stars 0 forks source link

일정 불러오기 /api/v1/import 500 에러 #52

Closed call-me-bammer closed 2 weeks ago

call-me-bammer commented 2 weeks ago

13.으로 시작하는 개발 서벌로 해당 형식으로 요청보내면 DioError에서 500 응답코드를 냅니다.

@inmonim https://api.calinify.com/으로 전환해서도 8080, 5051 포트 구분이 필요한 것인지, 운영서버에만 작업하여 해당 api가 개발서버에서는 죽어있는 것인지 물어봅니다.

FormData formData = FormData.fromMap({
  // TODO. use /api/v1/user/
  'user_id': dotenv.env['USER_ID']!,
  'ics_file': await MultipartFile.fromFile(
    file.path!,
    filename: file.name,
  ),
});

Response response = await dio.post(
  dotenv.env['BACKEND_TRANSPORT_URL']! +
      '/api/v1/import',
  data: formData,
  options: Options(headers: {
    'Content-Type': 'multipart/form-data',
    'authorization': 'Bearer $refreshToken',
  }),
);
inmonim commented 2 weeks ago

운영 서버와 데브 서버 모두 8080으로 시작하는 메인 스프링 서버로만 요청을 보내면 됩니다.

ai 서버와 transport 서버는 유저와 클라이언트가 애초에 직접 접근할 수가 엄서용. dev 서버에서만 /docs로 직접 접근이 가능합니다.

spring서버에서 transport(import/export) API를 다 만들었는데, 아직 안 올려놨습니당

dev랑 prod 전부 올려 놓을 테니 여기로 데이터를 보내면 되겠습니다

call-me-bammer commented 2 weeks ago

@inmonim 아래와 같이 처리하도록 변경하였으나 에러 로그 다음과 같습니다.

I/flutter (11516): DioError 응답 코드: 500
I/flutter (11516): DioError 응답 데이터: {timestamp: 2024-11-13T09:26:52.867+00:00, status: 500, error: Internal Server Error, path: /api/v1/transport/import}
  FormData formData = FormData.fromMap({
    'file': await MultipartFile.fromFile(
      file.path!,
      filename: file.name,
    ),
  });

  Response response = await dio.post(
    dotenv.env['BACKEND_MAIN_URL']! +
        '/api/v1/transport/import',
    data: formData,
    options: Options(headers: {
      'Content-Type': 'multipart/form-data',
      'authorization': 'Bearer $refreshToken',
    }),
  );

  // 응답 확인
  print('응답 코드: ${response.statusCode}');
  print('응답 데이터: ${response.data}');

  if (response.statusCode == 200) {
    print('파일 업로드 성공');
  }
} on DioError catch (e) {
  /* Dio Error Handling */
}

이건 요청 보내는 버튼을 누르자마자 밑으로 다 찍힌 전체 로그입니다.

I/ViewRootImpl@6bd906a[MainActivity](11516): handleAppVisibility mAppVisible=false visible=true
I/SurfaceView@c4e9761(11516): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{c4e9761 G.E...... ......I. 0,0-720,1516} of ViewRootImpl@6bd906a[MainActivity]
D/SurfaceView@c4e9761(11516): updateSurface: surface is not valid
D/OpenGLRenderer(11516): setSurface called with nullptr
I/ViewRootImpl@6bd906a[MainActivity](11516): Relayout returned: old=(0,0,720,1600) new=(0,0,720,1600) req=(720,1600)4 dur=12 res=0x1 s={false 0} ch=false fn=-1
D/SurfaceView@c4e9761(11516): updateSurface: surface is not valid
I/ViewRootImpl@6bd906a[MainActivity](11516): stopped(false) old=true
I/FilePickerUtils(11516): Caching from URI: content://com.android.providers.media.documents/document/document%3A1000000030
D/SurfaceView@c4e9761(11516): updateSurface: surface is not valid
I/ViewRootImpl@6bd906a[MainActivity](11516): stopped(false) old=false
I/SurfaceView@c4e9761(11516): onWindowVisibilityChanged(0) false io.flutter.embedding.android.FlutterSurfaceView{c4e9761 V.E...... ......ID 0,0-720,1516} of ViewRootImpl@6bd906a[MainActivity]
D/SurfaceView@c4e9761(11516): updateSurface: surface is not valid
D/OpenGLRenderer(11516): setSurface called with nullptr
D/FilePickerUtils(11516): File loaded and cached at:/data/user/0/com.calinify.mobile/cache/file_picker/1731490012833/import_text.ics
D/FilePickerDelegate(11516): File path:[com.mr.flutter.plugin.filepicker.FileInfo@3459555]
I/ViewRootImpl@6bd906a[MainActivity](11516): Relayout returned: old=(0,0,720,1600) new=(0,0,720,1600) req=(720,1600)0 dur=11 res=0x7 s={true 505912016896} ch=true fn=-1
D/OpenGLRenderer(11516): eglCreateWindowSurface
I/SurfaceView@c4e9761(11516): windowStopped(false) true io.flutter.embedding.android.FlutterSurfaceView{c4e9761 V.E...... ......ID 0,0-720,1516} of ViewRootImpl@6bd906a[MainActivity]
I/SurfaceView@c4e9761(11516): pST: sr = Rect(0, 0 - 720, 1516) sw = 720 sh = 1516
I/SurfaceView@c4e9761(11516): onSSPAndSRT: pl = 0 pt = 0 sx = 1.0 sy = 1.0
I/SurfaceView@c4e9761(11516): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@27e11be
I/SurfaceView@c4e9761(11516): updateSurface: mVisible = true mSurface.isValid() = true
I/SurfaceView@c4e9761(11516): updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
I/SurfaceView@c4e9761(11516): surfaceCreated 1 #1 io.flutter.embedding.android.FlutterSurfaceView{c4e9761 V.E...... ......ID 0,0-720,1516}
I/SurfaceView@c4e9761(11516): surfaceChanged (720,1516) 1 #1 io.flutter.embedding.android.FlutterSurfaceView{c4e9761 V.E...... ......ID 0,0-720,1516}
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] dp(1) 1 android.view.SurfaceView.updateSurface:1375 android.view.SurfaceView.setWindowStopped:383 android.view.SurfaceView.surfaceCreated:2051 
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] pdf(0) 1 android.view.SurfaceView.notifyDrawFinished:599 android.view.SurfaceView.performDrawFinished:586 android.view.SurfaceView.$r8$lambda$st27mCkd9jfJkTrN_P3qIGKX6NY:0 
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] rdf()
D/ViewRootImpl@6bd906a[MainActivity](11516): reportDrawFinished (fn: -1) 
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] dp(1) 1 android.view.ViewRootImpl.reportNextDraw:11420 android.view.ViewRootImpl.performTraversals:4193 android.view.ViewRootImpl.doTraversal:2919 
D/ViewRootImpl@6bd906a[MainActivity](11516): Creating frameDrawingCallback nextDrawUseBlastSync=false reportNextDraw=true hasBlurUpdates=false
D/ViewRootImpl@6bd906a[MainActivity](11516): Creating frameCompleteCallback
I/SurfaceView@c4e9761(11516): uSP: rtp = Rect(0, 0 - 720, 1516) rtsw = 720 rtsh = 1516
I/SurfaceView@c4e9761(11516): onSSPAndSRT: pl = 0 pt = 0 sx = 1.0 sy = 1.0
I/SurfaceView@c4e9761(11516): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@cdeab6a fN = 1 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:319 
I/SurfaceView@c4e9761(11516): aOrMT: vR.mWNT, vR = ViewRootImpl@6bd906a[MainActivity]
I/ViewRootImpl@6bd906a[MainActivity](11516): mWNT: t = android.view.SurfaceControl$Transaction@cdeab6a fN = 1 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 
I/ViewRootImpl@6bd906a[MainActivity](11516): mWNT: merge t to BBQ
D/ViewRootImpl@6bd906a[MainActivity](11516): Received frameDrawingCallback frameNum=1. Creating transactionCompleteCallback=false
D/ViewRootImpl@6bd906a[MainActivity](11516): Received frameCompleteCallback  lastAcquiredFrameNum=1 lastAttemptedDrawFrameNum=1
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] pdf(0) 1 android.view.ViewRootImpl.lambda$addFrameCompleteCallbackIfNeeded$3$ViewRootImpl:4995 android.view.ViewRootImpl$$ExternalSyntheticLambda16.run:6 android.os.Handler.handleCallback:938 
I/ViewRootImpl@6bd906a[MainActivity](11516): [DP] rdf()
D/ViewRootImpl@6bd906a[MainActivity](11516): reportDrawFinished (fn: -1) 
D/InsetsSourceConsumer(11516): ensureControlAlpha: for ITYPE_NAVIGATION_BAR on com.calinify.mobile/com.calinify.mobile.MainActivity
D/InsetsSourceConsumer(11516): ensureControlAlpha: for ITYPE_STATUS_BAR on com.calinify.mobile/com.calinify.mobile.MainActivity
I/ViewRootImpl@6bd906a[MainActivity](11516): MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager(11516): startInputInner - Id : 0
I/InputMethodManager(11516): startInputInner - mService.startInputOrWindowGainedFocus
I/flutter (11516): /colorSet/ resp: [{colorSetId: 1, colorName: caliblue-300, hexCode: #2457A5}, {colorSetId: 2, colorName: caliorange-400, hexCode: #F15928}, {colorSetId: 3, colorName: red-400, hexCode: #D31B2A}, {colorSetId: 4, colorName: 테스트, hexCode: string}]
I/flutter (11516): DioError 응답 코드: 500
I/flutter (11516): DioError 응답 데이터: {timestamp: 2024-11-13T09:26:52.867+00:00, status: 500, error: Internal Server Error, path: /api/v1/transport/import}
call-me-bammer commented 2 weeks ago

구글 캘린더에서 내보내기 기능으로 추출한 ics를 업로드하고, Workbench에서 calendars 테이블의 prod_id로 -//Google Inc//Google Calendar 70.9054//EN가 찍히는 거 확인했습니다. 53번 달력으로 제대로 동작합니다.

I/flutter (16357): 응답 코드: 200
I/flutter (16357): 응답 데이터: {calendarId: 53, eventCount: 17, failCount: 0}
I/flutter (16357): 파일 업로드 성공

테스트를 처음에 ics를 만들어서 했던 게 이상한 접근이었는데 전에 대면으로 했던 이야기 중에 이벤트마다 고유한 uid 관련한 게 있었는데 그것과 관련있나 합니다...

uid를 무시하면 200 응답코드를 받으나, failCount에 이벤트 개수만큼 쌓이면서 'None'이라는 이름으로 이벤트가 없는 달력이 생성되긴 합니다.

uid를 강제로 구글 캘린더 ics에 있던 이벤트에서 아무거나 바꿔끼니까 eventCount는 올라가는데 54번 캘린더에 db에 저장된 이벤트는 없습니다.

으흑... @inmonim 아무튼 ics를 변태처럼 만들어서 등록하는 사람은 없을테니 그만 알아보고 닫겠습니다...

I/flutter (16357): 응답 코드: 200
I/flutter (16357): 응답 데이터: {calendarId: 52, eventCount: 0, failCount: 4}
I/flutter (16357): 파일 업로드 성공