Skip to content

Commit

Permalink
fix(ci/cd): 202401111
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Parvulescu committed Jan 11, 2024
1 parent 97e4eac commit a0a01c5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion packages/platform-middleware/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RollupError } from '@proofzero/errors'
import { IdentityURNSpace, type IdentityURN } from '@proofzero/urns/identity'
import { getAuthzTokenFromReq } from '@proofzero/utils'
import { checkToken } from '@proofzero/utils/token'
Expand Down
11 changes: 6 additions & 5 deletions packages/platform-middleware/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TraceSpan {
export const generateTraceSpan = (
headers?: Record<string, string> | Headers
): TraceSpan => {
let result: TraceSpan
let result: TraceSpan | undefined

if (headers) {
let traceparent
Expand All @@ -56,7 +56,7 @@ export const generateTraceSpan = (
if (traceparent) result = createTraceSpan(traceparent as TraceParent)
}
//If result hasn't been set (due to missing traceparent in header), create new trace
if (!result!) result = createTraceSpan()
if (!result) result = createTraceSpan()
return result
}

Expand All @@ -77,21 +77,22 @@ const getTraceParentForSpan = (span: TraceSpan): TraceParent => {
const createTraceSpan = (traceparent?: TraceParent): TraceSpan => {
const newSpanId = generateRandomString(16)

let result: TraceSpan
let result: TraceSpan | undefined
if (traceparent) {
const parsedTraceparent = traceparent.split('-')
console.assert(
parsedTraceparent.length === 4,
`traceparent value: ${traceparent}`
)
const [_, traceId, parentId] = parsedTraceparent
const traceId = parsedTraceparent[1]
const parentId = parsedTraceparent[2]
if (traceId && parentId)
result = new TraceSpan(traceId, newSpanId, parentId)
}

//If there was no traceparent or the values weren't valid, we create a new one
//with no parentId
if (!result!) {
if (!result) {
result = new TraceSpan(generateRandomString(32), newSpanId)
}
return result
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const createAnalyticsEvent = async ({
eventName: string
apiKey: string
distinctId: string
properties?: Record<string, any>
properties?: Record<string, unknown>
}) => {
const body = JSON.stringify({
api_key: apiKey,
Expand Down
5 changes: 3 additions & 2 deletions packages/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ export function getRollupReqFunctionErrorWrapper(
if (e instanceof Response) return e as Response

const error = getErrorCause(e) as Error
const { stack, ...otherProps } = error
delete error.stack

const traceparent = context.traceSpan
? (context.traceSpan as TraceSpan).getTraceParent()
: 'No trace information'
const result = {
...otherProps,
...error,
message: error.message,
originalError: e,
traceparent,
Expand Down
6 changes: 6 additions & 0 deletions platform/object/src/jsonrpc/methods/putObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { initObjectNodeByName } from '../../nodes'
import { Visibility } from '../../types'

import { getBaseKey, getObjectKey } from '../../utils'
import { InternalServerError } from '@proofzero/errors'

export const PutObjectInput = z.object({
namespace: z.string(),
Expand Down Expand Up @@ -50,6 +51,11 @@ export const putObjectMethod = async ({
JSON.stringify(value)
)
await node.class.set(index.version, index.visibility)
if (!metadata) {
throw new InternalServerError({
message: 'Metadata is null',
})
}
return {
size: metadata.size,
version: index.version,
Expand Down

0 comments on commit a0a01c5

Please sign in to comment.