Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] JSON parsing error is showing up in log when openeing the Dasbhoard viewmodel #359

Open
OmarIthawi opened this issue Mar 20, 2024 · 3 comments · Fixed by #360
Open
Assignees

Comments

@OmarIthawi
Copy link
Member

OmarIthawi commented Mar 20, 2024

Steps to reproduce

  1. Where are you starting? What can you see?

A newly compiled app from develop branch connected to my server blue.zeitlabs.com which is Open edX master backend (more recent the Quince).

  1. What do you click?

The dashboard button.

We got this error in the mobile error:

valueNotFound(Swift.Array<Swift.String>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "enrollments", intValue: nil), CodingKeys(stringValue: "results", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "course", intValue: nil), CodingKeys(stringValue: "discussion_url", intValue: nil)], debugDescription: "Cannot get unkeyed decoding container -- found null value instead", underlyingError: nil))

HTTP Request

Request: GET https://blue.zeitlabs.com/api/mobile/v3/users/omarstudent/course_enrollments?page=1

{
  "configs": {
    "iap_configs": {}
  },
  "enrollments": {
    "next": null,
    "previous": null,
    "count": 2,
    "num_pages": 1,
    "current_page": 1,
    "start": 0,
    "results": [
      {
        "audit_access_expires": null,
        "created": "2024-02-29T12:51:54.025316Z",
        "mode": "audit",
        "is_active": true,
        "course": {
          "id": "course-v1:futurex+test101+2024",
          "name": "The Test Bank example course",
          "number": "test101",
          "org": "futurex",
          "start": "2020-01-01T00:00:00Z",
          "start_display": "Jan. 1, 2020",
          "start_type": "timestamp",
          "end": null,
          "dynamic_upgrade_deadline": null,
          "subscription_id": "course_MNXXK4TTMUWXMMJ2MZ2XI5LSMV4CW5DFON2DCMBRFMZDAMRU",
          "courseware_access": {
            "has_access": true,
            "error_code": null,
            "developer_message": null,
            "user_message": null,
            "additional_context_user_message": null,
            "user_fragment": null
          },
          "media": {
            "course_image": {
              "uri": "/asset-v1:futurex+test101+2024+type@asset+block@depositphotos_11930317-stock-photo-scantron-test-blocks-and-pencil.jpeg",
              "name": "Course Image"
            }
          },
          "course_image": "/asset-v1:futurex+test101+2024+type@asset+block@depositphotos_11930317-stock-photo-scantron-test-blocks-and-pencil.jpeg",
          "course_about": "https://blue.zeitlabs.com/courses/course-v1:futurex+test101+2024/about",
          "course_sharing_utm_parameters": {
            "facebook": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=facebook",
            "twitter": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=twitter"
          },
          "course_updates": "https://blue.zeitlabs.com/api/mobile/v3/course_info/course-v1:futurex+test101+2024/updates",
          "course_handouts": "https://blue.zeitlabs.com/api/mobile/v3/course_info/course-v1:futurex+test101+2024/handouts",
          "discussion_url": null,
          "video_outline": null,
          "is_self_paced": false
        },
        "certificate": {},
        "course_modes": [
          {
            "slug": "audit",
            "sku": null,
            "android_sku": null,
            "ios_sku": null,
            "min_price": 0
          }
        ]
      },
      {
        "audit_access_expires": null,
        "created": "2024-02-29T12:51:51.983028Z",
        "mode": "audit",
        "is_active": true,
        "course": {
          "id": "course-v1:i18n+i18n+i81n",
          "name": "Learn HTML the hard way",
          "number": "i18n",
          "org": "i18n",
          "start": "2030-01-01T00:00:00Z",
          "start_display": null,
          "start_type": "empty",
          "end": null,
          "dynamic_upgrade_deadline": null,
          "subscription_id": "course_MNXXK4TTMUWXMMJ2NEYTQ3RLNEYTQ3RLNE4DC3Q_",
          "courseware_access": {
            "has_access": false,
            "error_code": "course_not_started",
            "developer_message": "Course has not started",
            "user_message": "Course has not started",
            "additional_context_user_message": null,
            "user_fragment": null
          },
          "media": {
            "course_image": {
              "uri": "/asset-v1:i18n+i18n+i81n+type@asset+block@depositphotos_667560896-stock-photo-word-cloud-online-courses-concept.jpg",
              "name": "Course Image"
            }
          },
          "course_image": "/asset-v1:i18n+i18n+i81n+type@asset+block@depositphotos_667560896-stock-photo-word-cloud-online-courses-concept.jpg",
          "course_about": "https://blue.zeitlabs.com/courses/course-v1:i18n+i18n+i81n/about",
          "course_sharing_utm_parameters": {
            "facebook": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=facebook",
            "twitter": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=twitter"
          },
          "course_updates": "https://blue.zeitlabs.com/api/mobile/v3/course_info/course-v1:i18n+i18n+i81n/updates",
          "course_handouts": "https://blue.zeitlabs.com/api/mobile/v3/course_info/course-v1:i18n+i18n+i81n/handouts",
          "discussion_url": null,
          "video_outline": null,
          "is_self_paced": false
        },
        "certificate": {},
        "course_modes": [
          {
            "slug": "audit",
            "sku": null,
            "android_sku": null,
            "ios_sku": null,
            "min_price": 0
          }
        ]
      }
    ]
  }
}

Screenshot

image

Outcome

What did you expect?

See list of courses.

What happened instead?

I see empty list dashboard.

Your phone model

iPhone Simulator

Operating system version

iPhone 15 Pro simulator - iOS 17.2

Application version

develop branch (v1.0.0)

@gurhub
Copy link

gurhub commented Mar 20, 2024

Hey @volodymyr-chekyrta, first of all, thanks for the solution and merge. After your solution, I manually got the raw Data_Dashboard.swift file content and tried it on my machine and I received another parsing error on Xcode's console:

CodingKeys(stringValue: "start_display", intValue: nil)], debugDescription: "Cannot get unkeyed decoding container -- found null value instead", underlyingError: nil))

By following your method, I was able to remove the start_display key from the Data_Dashboard.swift file. And run and test again. Now everything is working as expected.

Best

@volodymyr-chekyrta
Copy link
Contributor

@gurhub makes sense; the startDisplaying field is unused as well.
I've updated PR ✅
Thank you!

@gurhub
Copy link

gurhub commented Mar 20, 2024

@volodymyr-chekyrta you're welcome!
Best

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 a pull request may close this issue.

3 participants