Skip to content

PROD-2156 #6383

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

Merged
merged 6 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ workflows:
filters:
branches:
only:
- circleci-fix
- debug-CMS-error
# This is alternate dev env for parallel testing
- "build-qa":
context : org-global
Expand Down
46 changes: 27 additions & 19 deletions src/shared/actions/contentful.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getService } from 'services/contentful';
import { config, redux } from 'topcoder-react-utils';
import { removeTrailingSlash } from 'utils/url';
import { menuItemBuilder, target as urlTarget } from 'utils/contentful';
import { services } from 'topcoder-react-lib';
import { services, logger } from 'topcoder-react-lib';

const ERRMSG_UNKNOWN_TARGET = 'Unknown action target';

Expand Down Expand Up @@ -91,15 +91,19 @@ async function getContentDone(operationId, contentId, target, preview, spaceName
environment,
});
let content;
switch (target) {
case TARGETS.ASSETS:
content = await service.getAsset(contentId);
break;
case TARGETS.ENTRIES:
content = await service.getEntry(contentId);
break;
default:
throw new Error(ERRMSG_UNKNOWN_TARGET);
try {
switch (target) {
case TARGETS.ASSETS:
content = await service.getAsset(contentId);
break;
case TARGETS.ENTRIES:
content = await service.getEntry(contentId);
break;
default:
throw new Error(ERRMSG_UNKNOWN_TARGET);
}
} catch (e) {
logger.error('getContentDone error', e);
}

return {
Expand Down Expand Up @@ -141,15 +145,19 @@ async function queryContentDone(operationId, queryId, target,
environment,
});
let data;
switch (target) {
case TARGETS.ASSETS:
data = await service.queryAssets(query);
break;
case TARGETS.ENTRIES:
data = await service.queryEntries(query);
break;
default:
throw new Error(ERRMSG_UNKNOWN_TARGET);
try {
switch (target) {
case TARGETS.ASSETS:
data = await service.queryAssets(query);
break;
case TARGETS.ENTRIES:
data = await service.queryEntries(query);
break;
default:
throw new Error(ERRMSG_UNKNOWN_TARGET);
}
} catch (e) {
logger.error('queryContentDone error', e);
}

return {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/reducers/contentful/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function create(init) {
const spaceName = _.get(payload, 'spaceName') || config.CONTENTFUL.DEFAULT_SPACE_NAME;
const environment = _.get(payload, 'environment') || config.CONTENTFUL.DEFAULT_ENVIRONMENT;
const res = _.get(newState, `${spaceName}.${environment}`);
if (error || !res) {
logger.log('CMS-related error', error, res, `${spaceName}.${environment}`, newState, payload, config.CONTENTFUL.DEFAULT_SPACE_NAME, config.CONTENTFUL.DEFAULT_ENVIRONMENT);
if ((error && payload && payload.sys && payload.sys.id !== 'NotFound') || !res) {
logger.log('CMS-related error', JSON.stringify(action), config.CONTENTFUL.DEFAULT_SPACE_NAME, config.CONTENTFUL.DEFAULT_ENVIRONMENT, JSON.stringify(res), JSON.stringify(newState));
return state;
}
const st = state[spaceName][environment];
Expand Down