@adobe/helix-html-pipeline 3.6.2 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/json-pipe.js +47 -35
- package/src/steps/authenticate.js +2 -1
- package/test/StaticS3Loader.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.6.3](https://github.com/adobe/helix-html-pipeline/compare/v3.6.2...v3.6.3) (2022-11-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle errors when loading config ([#180](https://github.com/adobe/helix-html-pipeline/issues/180)) ([f4f4b5f](https://github.com/adobe/helix-html-pipeline/commit/f4f4b5ff4f687331c2ec321e53662519cc428eb6)), closes [#179](https://github.com/adobe/helix-html-pipeline/issues/179)
|
|
7
|
+
|
|
1
8
|
## [3.6.2](https://github.com/adobe/helix-html-pipeline/compare/v3.6.1...v3.6.2) (2022-10-31)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/json-pipe.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
+
import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
|
|
12
13
|
import fetchConfigAll from './steps/fetch-config-all.js';
|
|
13
14
|
import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
|
|
14
15
|
import { PipelineResponse } from './PipelineResponse.js';
|
|
@@ -17,6 +18,7 @@ import { extractLastModified, updateLastModified } from './utils/last-modified.j
|
|
|
17
18
|
import { authenticate } from './steps/authenticate.js';
|
|
18
19
|
import fetchConfig from './steps/fetch-config.js';
|
|
19
20
|
import { getPathInfo } from './utils/path.js';
|
|
21
|
+
import { PipelineStatusError } from './PipelineStatusError.js';
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Checks the fstab for folder mapping entries and then re-adjusts the path infos if needed.
|
|
@@ -74,48 +76,58 @@ export async function jsonPipe(state, req) {
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
try {
|
|
80
|
+
// fetch config and apply the folder mapping
|
|
81
|
+
await fetchConfig(state, req);
|
|
82
|
+
await folderMapping(state);
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
// fetch data from content bus
|
|
85
|
+
const { path } = state.info;
|
|
86
|
+
state.timer?.update('json-fetch');
|
|
87
|
+
let dataResponse = await s3Loader.getObject('helix-content-bus', `${contentBusId}/${partition}${path}`);
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
// if not found, fall back to code bus
|
|
90
|
+
if (dataResponse.status === 404) {
|
|
91
|
+
dataResponse = await s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}${path}`);
|
|
92
|
+
}
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// if still not found, return status
|
|
95
|
+
if (dataResponse.status !== 200) {
|
|
96
|
+
if (dataResponse.status < 500) {
|
|
97
|
+
await fetchConfigAll(state, req, dataResponse);
|
|
98
|
+
await setCustomResponseHeaders(state, req, dataResponse);
|
|
99
|
+
}
|
|
100
|
+
return dataResponse;
|
|
96
101
|
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
const data = dataResponse.body;
|
|
102
|
+
const data = dataResponse.body;
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
// filter data
|
|
105
|
+
const response = jsonFilter(state, data, {
|
|
106
|
+
limit: limit ? Number.parseInt(limit, 10) : undefined,
|
|
107
|
+
offset: offset ? Number.parseInt(offset, 10) : undefined,
|
|
108
|
+
sheet,
|
|
109
|
+
raw: limit === undefined && offset === undefined && sheet === undefined,
|
|
110
|
+
});
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
// set last-modified
|
|
113
|
+
updateLastModified(state, response, extractLastModified(dataResponse.headers));
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
// set surrogate key
|
|
116
|
+
response.headers.set('x-surrogate-key', `${contentBusId}${path}`.replace(/\//g, '_'));
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
// Load config-all and set response headers
|
|
119
|
+
await fetchConfigAll(state, req, response);
|
|
120
|
+
await authenticate(state, req, response);
|
|
121
|
+
await setCustomResponseHeaders(state, req, response);
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
return response;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
const res = new PipelineResponse('', {
|
|
126
|
+
status: e instanceof PipelineStatusError ? e.code : 500,
|
|
127
|
+
});
|
|
128
|
+
const level = res.status >= 500 ? 'error' : 'info';
|
|
129
|
+
log[level](`pipeline status: ${res.status} ${e.message}`, e);
|
|
130
|
+
res.headers.set('x-error', cleanupHeaderValue(e.message));
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
121
133
|
}
|
|
@@ -72,7 +72,8 @@ export async function authenticate(state, req, res) {
|
|
|
72
72
|
res.error = 'forbidden.';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// set some response headers
|
|
75
|
+
// set some response headers for deferred edge authentication
|
|
76
|
+
// AdobePatentID="P11443-US"
|
|
76
77
|
res.headers.set('x-hlx-auth-allow', allows.join(','));
|
|
77
78
|
if (authInfo.profile) {
|
|
78
79
|
res.headers.set('x-hlx-auth-iss', authInfo.profile.iss);
|
package/test/StaticS3Loader.js
CHANGED
|
@@ -34,6 +34,11 @@ export class StaticS3Loader {
|
|
|
34
34
|
body: '',
|
|
35
35
|
headers: new Map(),
|
|
36
36
|
};
|
|
37
|
+
if (response instanceof Error) {
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.log(`StaticS3Loader: failing ${bucketId}/${key} -> ${response.message}`);
|
|
40
|
+
throw response;
|
|
41
|
+
}
|
|
37
42
|
// eslint-disable-next-line no-console
|
|
38
43
|
console.log(`StaticS3Loader: loading ${bucketId}/${key} -> ${response.status}`);
|
|
39
44
|
return response;
|