Skip to content

Commit

Permalink
GQL-80: Adds content-type header to subscription ingest requests. Fix…
Browse files Browse the repository at this point in the history
…es undefined request id in error message
  • Loading branch information
macrouch committed Oct 4, 2024
1 parent b9548fe commit d2f9e08
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cmr/concepts/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ export default class Subscription extends Concept {
// Use the provided native id and provider id
const { nativeId = uuidv4() } = params

super.ingest(data, requestedKeys, providedHeaders, {
const headers = {
...providedHeaders,
'Content-Type': 'application/vnd.nasa.cmr.umm+json'
}

super.ingest(data, requestedKeys, headers, {
path: `ingest/subscriptions/${encodeURIComponent(nativeId)}`
})
}
Expand Down
3 changes: 3 additions & 0 deletions src/datasources/__tests__/subscription.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ describe('subscription#ingest', () => {
.defaultReplyHeaders({
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.matchHeader('Content-Type', 'application/vnd.nasa.cmr.umm+json')
.put(/ingest\/subscriptions\/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed/, JSON.stringify({
CollectionConceptId: 'C100000-EDSC',
EmailAddress: 'test@example.com',
Expand Down Expand Up @@ -429,6 +430,7 @@ describe('subscription#ingest', () => {
.defaultReplyHeaders({
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.matchHeader('Content-Type', 'application/vnd.nasa.cmr.umm+json')
.put(/ingest\/subscriptions\/test-guid/, JSON.stringify({
CollectionConceptId: 'C100000-EDSC',
EmailAddress: 'test@example.com',
Expand Down Expand Up @@ -516,6 +518,7 @@ describe('subscription#ingest', () => {
test('catches errors received from ingestCmr', async () => {
nock(/example-cmr/)
.put(/ingest\/subscriptions\/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed/)
.matchHeader('Content-Type', 'application/vnd.nasa.cmr.umm+json')
.reply(500, {
errors: ['HTTP Error']
}, {
Expand Down
3 changes: 2 additions & 1 deletion src/graphql/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ export default startServerAndCreateLambdaHandler(
collectionLoader: new DataLoader(getCollectionsById, {
cacheKeyFn: (obj) => obj.conceptId
}),
headers: requestHeaders
headers: requestHeaders,
requestId: newRequestId
}
},
middleware: [
Expand Down
2 changes: 2 additions & 0 deletions src/types/subscription.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,6 @@ type SubscriptionMutationResponse {
conceptId: String
"The revision of the subscription."
revisionId: String
"The native id of the subscription."
nativeId: String
}

0 comments on commit d2f9e08

Please sign in to comment.