Switch Numbers to Constants#1581
Conversation
|
@Nespina24 Thank you for looking into this and the PR. Here are my initial thoughts:
|
|
@huss Thanks for taking the time to review my issue.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@huss @omarraf My last commit should have gotten the remaining files that use the 'HTTP_CODES' import. I still get a few test failures, such as in I'm not sure what the next steps should be at this point, so any review or feedback is appreciated. |
@Nespina24 & @omarraf When I run this locally, I only occasionally see the failures. I am trying to figure it out but I'm assuming this isn't an issue with this PR. Thus, I don't think you need to worry about it for this PR. I think it always passes on GitHub CI so it should not hold this up. (This may indicate it is a timing/speed issue with the code.) Know that I'm looking at other aspects of the PR to move it forward. To get all the comments straight, I tried to use strike-through on anything that I think is resolved in previous comments. |
huss
left a comment
There was a problem hiding this comment.
@Nespina24 Thank you for the updated code. First, I think this is close enough that it would be good to have it converted from a draft PR to a regular one. Is that okay with you? If so, will you do it or would you like me to?
I have now gone through every file and change to look at them. I want to thank you for being careful as I found virtually nothing. I have made a few, minor comments to consider.
I also swept the code to try to catch any places where numbers were used instead of the new constants for return code. Files with codes still present:
- src/server/services/csvPipeline/success.js: 200, 400
- src/server/test/web/csvPipelineTest.js:200, 400
- src/server/test/web/groups.js: 200, 203, 400, 401, 403
- src/server/test/web/login.js: 200, 401
- src/server/test/web/maps.js: 200, 403, 500
- src/server/test/web/meters.js: 200, 403, 500
- src/server/test/web/obviusTest.js: 200, 401, 406
- src/server/test/web/preferencesTest.js: 200, 403
- src/server/test/web/usersTest.js: 200, 400, 403
- src/server/test/web/version.js: 200
- src/server/services/csvPipeline/CustomErrors.js: 400
- src/server/app.js: 404
- src/server/services/csvPipeline/failure.js: 500
- src/server/services/csvPipeline/saveCsv.js: 500
- src/server/services/csvPipeline/uploadMeters.js: 500
Would you be interested/willing to fix these up as part of this PR or would you prefer someone else to take that on? Note this does not include any open PRs and that will be done as work outside this effort/PR. I'm asking since it would be nice to get this merged in the near future so other places that are coming can use the new constants in that new code.
Please let me know if anything is not clear, you have thoughts/questions or need any help.
After adding debug statements, I think I may have an idea of why this is happening. I won't be sure until a fix is figured out and tested. Since this started here, I'm adding some details. It is tricky to get this to fail but one time there was only the first log message and not the later one that the test expects so it does not get any. After thinking about it, I wondered if the code was not waiting on the log msg to be inserted. Sure enough, OED does not hold up the code to log errors so it can continue. Thus, there is currently no guarantee that the log message will be in the DB after the log route returns. I suspect it does not happen very often but sometimes the request to get the filtered logs happens to execute before the new log is entered. Since GitHub is faster than most developer machines it is not seen in that case but sometimes a local machine takes too long. Again, further testing is needs to make sure this is really happening. Now the fix is uncertain. One bandaid approach (not a good way) is to put in a delay in the test so the second request is delayed and hope/assume it has completed. Another is to retry after a delay when the first attempt does not get the log message. A better fix would be to resolve the issue but OED does not want to wait for all logs to be in the DB (await) before proceeding. Maybe there could be a switch to await during testing but not at other times but this is a non-trivial change. Again, more thought and work in the future is needed. I welcome any thoughts. |
|
@huss & @omarraf It's a relief to hear that you can pass I had one last question about the pull request description: Do I need to tick off any of "Note merging this changes the database configuration" or "This change requires a documentation update" or should I leave them unchecked? I was wondering if the addition of the file |
Thank you for asking. The documentation refers to the user help files (most of the time). Since this did not change how the code functions but how it is implemented there is no need to check that box. Once this is merged, all developers will see the change and it should be easy to use this in any new code. As for database configuration, this does not touch the setup of the DB so that does not need to be checked. I have this on my list to review again. If you want any advise on other OED work you could do then just let me know. |
|
For the record, I just pushed a commit for app.js to fix a couple of codes that I missed before so I am fixing. It was much easier to check once most had been updated in this PR. |
huss
left a comment
There was a problem hiding this comment.
@Nespina24 Thank you for the updated code. Review and testing found this work as desired. I want to thank you for all of your efforts and doing extra work to make this a holistic solution., Congratulations on your first accepted contribution to OED.
Description
Added constant imports throughout 64 src/server files in order to change hard-coded numeric values to fit the listed format in a newly added file src/server/util/httpCodes.js.
Fixes #1573
Type of change
Checklist
Limitations
No limitations.