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

error: Cannot read properties of undefined (reading 'concat') #375

Closed
liammulh opened this issue Feb 24, 2023 · 12 comments
Closed

error: Cannot read properties of undefined (reading 'concat') #375

liammulh opened this issue Feb 24, 2023 · 12 comments
Assignees

Comments

@liammulh
Copy link
Member

While checking the logs to see if my patch for #374 was working properly, I saw:

Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: post request received for /submitTranslation 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: sending mk/build-an-atom translation to be prepared for long-term storage 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: preparing translation of mk/build-an-atom for long-term storage 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: adding back dots to translation form data from client 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: making translation file contents for build-an-atom 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: getting sim metadata 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: returning sim metadata mutex 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: using cached sim metadata 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: returning sim metadata 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: getting sim names and titles 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: info: returning sim names and titles 
Feb 23 16:13:47 phet-server2.int.colorado.edu rosetta[375109]: error: Cannot read properties of undefined (reading 'concat') 
@liammulh liammulh self-assigned this Feb 24, 2023
@liammulh
Copy link
Member Author

This was an issue before restarting Rosetta for the fix in #374.

@liammulh
Copy link
Member Author

liammulh commented Feb 24, 2023

I searched for the error from the first instance of rosetta started, i.e. since we started Rosetta 2.0, (use /rosetta started in Vim's command mode) to now:

'<,'>s/error: Cannot read properties of undefined (reading 'concat')//gn

Here are the results:

19 matches on 19 lines

@liammulh
Copy link
Member Author

Out of curiosity, I searched for the total number of errors from the first instance of rosetta started:

'<,'>s/error//gn

Results:

36 matches on 36 lines

@liammulh
Copy link
Member Author

I put Rosetta in maintenance mode at 5 today (Feb 23 17:01:05).

@liammulh
Copy link
Member Author

liammulh commented Feb 24, 2023

I used Vim to get all the errors in one buffer:

     1	Feb 23 02:07:10 error: Request failed with status code 404 {"config":{"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/0.24.0"},"maxBodyLength":-1,"maxContentLength":-1,"method":"get","timeout":0,"transformRequest":[null],"transformResponse":[null],"transitional":{"clarifyTimeoutError":false,"forcedJSONParsing":true,"silentJSONParsing":true},"url":"https://phet.colorado.edu/sims/html/energy-skate-park/1.1.27/dependencies.json","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN"},"status":404}
     2	Feb 23 02:07:10 error: build request result: Error: Request failed with status code 500
     3	Feb 23 02:07:59 error: Request failed with status code 404 {"config":{"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/0.24.0"},"maxBodyLength":-1,"maxContentLength":-1,"method":"get","timeout":0,"transformRequest":[null],"transformResponse":[null],"transitional":{"clarifyTimeoutError":false,"forcedJSONParsing":true,"silentJSONParsing":true},"url":"https://phet.colorado.edu/sims/html/energy-skate-park/1.1.27/dependencies.json","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN"},"status":404}
     4	Feb 23 02:07:59 error: build request result: Error: Request failed with status code 500
     5	Feb 23 02:08:34 error: Request failed with status code 404 {"config":{"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/0.24.0"},"maxBodyLength":-1,"maxContentLength":-1,"method":"get","timeout":0,"transformRequest":[null],"transformResponse":[null],"transitional":{"clarifyTimeoutError":false,"forcedJSONParsing":true,"silentJSONParsing":true},"url":"https://phet.colorado.edu/sims/html/energy-skate-park/1.1.27/dependencies.json","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN"},"status":404}
     6	Feb 23 02:08:34 error: build request result: Error: Request failed with status code 500
     7	Feb 23 02:10:02 error: Request failed with status code 404 {"config":{"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/0.24.0"},"maxBodyLength":-1,"maxContentLength":-1,"method":"get","timeout":0,"transformRequest":[null],"transformResponse":[null],"transitional":{"clarifyTimeoutError":false,"forcedJSONParsing":true,"silentJSONParsing":true},"url":"https://phet.colorado.edu/sims/html/energy-skate-park/1.1.27/dependencies.json","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN"},"status":404}
     8	Feb 23 02:10:02 error: build request result: Error: Request failed with status code 500
     9	Feb 23 02:11:27 error: Request failed with status code 404 {"config":{"headers":{"Accept":"application/json, text/plain, */*","User-Agent":"axios/0.24.0"},"maxBodyLength":-1,"maxContentLength":-1,"method":"get","timeout":0,"transformRequest":[null],"transformResponse":[null],"transitional":{"clarifyTimeoutError":false,"forcedJSONParsing":true,"silentJSONParsing":true},"url":"https://phet.colorado.edu/sims/html/energy-skate-park/1.1.27/dependencies.json","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN"},"status":404}
    10	Feb 23 02:11:27 error: build request result: Error: Request failed with status code 500
    11	Feb 23 02:21:02 error: long term storage of pl/energy-skate-park failed
    12	Feb 23 02:31:17 error: long term storage of pl/energy-skate-park failed
    13	Feb 23 02:31:57 error: long term storage of pl/energy-skate-park failed
    14	Feb 23 02:36:39 error: long term storage of pl/energy-skate-park failed
    15	Feb 23 15:18:31 error: Not Found {"body":{"documentation_url":"https://docs.github.com/rest/reference/repos#get-repository-content","message":"Not Found"},"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-length":"113","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 23 Feb 2023 22:18:31 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","
    16	Feb 23 15:18:32 error: Not Found {"body":{"documentation_url":"https://docs.github.com/rest/reference/repos#get-repository-content","message":"Not Found"},"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-length":"113","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 23 Feb 2023 22:18:32 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","
    17	Feb 23 15:18:33 error: Not Found {"body":{"documentation_url":"https://docs.github.com/rest/reference/repos#get-repository-content","message":"Not Found"},"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-length":"113","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 23 Feb 2023 22:18:33 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","
    18	Feb 23 15:56:54 error: Cannot read properties of undefined (reading 'concat')
    19	Feb 23 15:57:07 error: Cannot read properties of undefined (reading 'concat')
    20	Feb 23 15:57:19 error: Cannot read properties of undefined (reading 'concat')
    21	Feb 23 15:57:48 error: Cannot read properties of undefined (reading 'concat')
    22	Feb 23 15:57:59 error: Cannot read properties of undefined (reading 'concat')
    23	Feb 23 15:58:21 error: Cannot read properties of undefined (reading 'concat')
    24	Feb 23 15:59:38 error: Cannot read properties of undefined (reading 'concat')
    25	Feb 23 16:02:13 error: Cannot read properties of undefined (reading 'concat')
    26	Feb 23 16:04:54 error: Cannot read properties of undefined (reading 'concat')
    27	Feb 23 16:06:09 error: Cannot read properties of undefined (reading 'concat')
    28	Feb 23 16:08:24 error: Cannot read properties of undefined (reading 'concat')
    29	Feb 23 16:08:44 error: Cannot read properties of undefined (reading 'concat')
    30	Feb 23 16:09:15 error: Cannot read properties of undefined (reading 'concat')
    31	Feb 23 16:09:55 error: Cannot read properties of undefined (reading 'concat')
    32	Feb 23 16:11:10 error: Cannot read properties of undefined (reading 'concat')
    33	Feb 23 16:13:16 error: Cannot read properties of undefined (reading 'concat')
    34	Feb 23 16:13:22 error: Cannot read properties of undefined (reading 'concat')
    35	Feb 23 16:13:47 error: Cannot read properties of undefined (reading 'concat')
    36	Feb 23 16:41:30 error: Cannot read properties of undefined (reading 'concat')

@liammulh
Copy link
Member Author

liammulh commented Feb 24, 2023

@liammulh
Copy link
Member Author

This is the pattern of logs we see for error: Cannot read properties of undefined (reading 'concat'):

Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: post request received for /submitTranslation
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: sending mk/build-an-atom translation to be prepared for long-term storage
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: preparing translation of mk/build-an-atom for long-term storage
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: adding back dots to translation form data from client
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: making translation file contents for build-an-atom
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: getting sim metadata
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: returning sim metadata mutex
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: using cached sim metadata
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: returning sim metadata
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: getting sim names and titles
Feb 23 16:41:30 phet-server2.int.colorado.edu rosetta[2132102]: info: returning sim names and titles

It looks like we are entering prepareTranslationForLongTermStorage, in which we enter makeTranslationFileContentsForRepo, where, on line 178, we try to use the .concat method on an array which should exist, but evidently doesn't in some cases:

else if ( translationModified ) {
logger.verbose( `the translation for ${stringKey}'s string was modified; adding it to the translation file for ${repo}` );
// Populate history object.
const newHistoryEntry = {
userId: translation.userId,
timestamp: translation.timestamp,
oldValue: oldTranslationFile[ stringKey ].value,
newValue: translationFormData[ stringKey ].translated,
explanation: null // this is no longer used, but for some reason we keep it around
};
// Add the history entry to the history array.
const newHistory = oldTranslationFile[ stringKey ].history.concat( [ newHistoryEntry ] );
// Add translated value and history to translation file.
translationFileContentsForRepo[ stringKey ] = {
value: translationFormData[ stringKey ].translated,
history: newHistory
};
}

I will check mk/build-an-atom for a string key that doesn't have a history array.

@liammulh
Copy link
Member Author

I looked at mk/build-an-atom, and I saw a file that contained string keys with only value sub-keys:

{
  "ion": {
    "value": "Јон"
  },
  "stableSlashUnstable": {
    "value": "Покажи  (не)стабилност"
  },
  "symbol": {
    "value": "Симбол"
  },
  "findTheElement": {
    "value": "Најди елемент:"
  },
  ...

This file was a manually ported legacy (Java/Flash) sim translation. These files are rare, but we need to handle them. These files where translated values were added manually don't have history arrays. See #329 (comment) for more info.

For each of the Cannot read properties of undefined (reading 'concat') errors, we need to check the string file to see if the issue is the same.

@liammulh
Copy link
Member Author

Patch
diff --git a/src/server/translationApi/makeTranslationFileContentsForRepo.js b/src/server/translationApi/makeTranslationFileContentsForRepo.js
index 454c24b..2532bd8 100644
--- a/src/server/translationApi/makeTranslationFileContentsForRepo.js
+++ b/src/server/translationApi/makeTranslationFileContentsForRepo.js
@@ -174,8 +174,13 @@ const makeTranslationFileContentsForRepo = async ( repo, translation ) => {
           explanation: null // this is no longer used, but for some reason we keep it around
         };
 
-        // Add the history entry to the history array.
-        const newHistory = oldTranslationFile[ stringKey ].history.concat( [ newHistoryEntry ] );
+        // Add the history entry to the history array. If the old translation file
+        // was a manually ported legacy (Java/Flash) sim translation, there might
+        // not be a history array. This is a rare-but-valid case that we need to
+        // handle. See https://github.com/phetsims/rosetta/issues/329#issuecomment-1371588737
+        // and https://github.com/phetsims/rosetta/issues/375#issuecomment-1444581287
+        // for more info.
+        const newHistory = ( oldTranslationFile[ stringKey ].history || [] ).concat( [ newHistoryEntry ] );
 
         // Add translated value and history to translation file.
         translationFileContentsForRepo[ stringKey ] = {

liammulh added a commit that referenced this issue Feb 24, 2023
@liammulh
Copy link
Member Author

liammulh commented Feb 24, 2023

For each of the Cannot read properties of undefined (reading 'concat') errors, we need to check the string file to see if the issue is the same.

  • 18 Feb 23 15:56:54 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 19 Feb 23 15:57:07 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 20 Feb 23 15:57:19 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 21 Feb 23 15:57:48 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 22 Feb 23 15:57:59 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 23 Feb 23 15:58:21 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 24 Feb 23 15:59:38 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 25 Feb 23 16:02:13 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 26 Feb 23 16:04:54 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 27 Feb 23 16:06:09 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 28 Feb 23 16:08:24 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 29 Feb 23 16:08:44 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 30 Feb 23 16:09:15 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 31 Feb 23 16:09:55 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 32 Feb 23 16:11:10 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 33 Feb 23 16:13:16 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 34 Feb 23 16:13:22 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 35 Feb 23 16:13:47 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes
  • 36 Feb 23 16:41:30 error: Cannot read properties of undefined (reading 'concat')
    • file: mk/build-an-atom
    • issue is the same? : yes

@liammulh
Copy link
Member Author

liammulh commented Feb 24, 2023

I will make a few changes to the patch, add some documentation about this rare case, and then I will test this.

  • configure to use the tests branch of babel
  • configure to perform string commits
  • configure to not send build requests
  • make changes to mk/build-an-atom string
  • "publish" changes
  • check logs and verify you don't see concat error, correct logs for not having history array
  • make changes to ab/chains
  • "publish" changes
  • check logs and verify you don't see any errors, correct logs for having history array

liammulh added a commit to phetsims/babel that referenced this issue Feb 25, 2023
Change this file to the master version of mk/build-an-atom to test the patch for phetsims/rosetta#375.
liammulh added a commit that referenced this issue Feb 25, 2023
liammulh added a commit that referenced this issue Feb 25, 2023
@liammulh liammulh added dependencies Pull requests that update a dependency file status:fixed-awaiting-deploy and removed dependencies Pull requests that update a dependency file labels Feb 25, 2023
@liammulh
Copy link
Member Author

This is deployed.

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

No branches or pull requests

1 participant