From aed10b58a990f159b3088f4a79be38a1607e2d41 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 25 Aug 2026 16:22:32 +0800 Subject: [PATCH] fix: report actionable error when url input is empty --- dist/index.js | 204 +++++++++++++++++++++++++------------------------- src/main.ts | 6 ++ 2 files changed, 110 insertions(+), 100 deletions(-) diff --git a/dist/index.js b/dist/index.js index f910e2e..57fd8d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4472,46 +4472,6 @@ CacheableRequest.CacheError = class extends Error { module.exports = CacheableRequest; -/***/ }), - -/***/ 5204: -/***/ ((module) => { - -"use strict"; - - -// We define these manually to ensure they're always copied -// even if they would move up the prototype chain -// https://nodejs.org/api/http.html#http_class_http_incomingmessage -const knownProps = [ - 'destroy', - 'setTimeout', - 'socket', - 'headers', - 'trailers', - 'rawHeaders', - 'statusCode', - 'httpVersion', - 'httpVersionMinor', - 'httpVersionMajor', - 'rawTrailers', - 'statusMessage' -]; - -module.exports = (fromStream, toStream) => { - const fromProps = new Set(Object.keys(fromStream).concat(knownProps)); - - for (const prop of fromProps) { - // Don't overwrite existing properties - if (prop in toStream) { - continue; - } - - toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop]; - } -}; - - /***/ }), /***/ 6358: @@ -4521,7 +4481,7 @@ module.exports = (fromStream, toStream) => { const PassThrough = (__nccwpck_require__(2203).PassThrough); -const mimicResponse = __nccwpck_require__(5204); +const mimicResponse = __nccwpck_require__(9991); const cloneResponse = response => { if (!(response && response.pipe)) { @@ -4546,7 +4506,7 @@ module.exports = cloneResponse; const {Transform, PassThrough} = __nccwpck_require__(2203); const zlib = __nccwpck_require__(3106); -const mimicResponse = __nccwpck_require__(9991); +const mimicResponse = __nccwpck_require__(9382); module.exports = response => { const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase(); @@ -4603,6 +4563,91 @@ module.exports = response => { }; +/***/ }), + +/***/ 9382: +/***/ ((module) => { + +"use strict"; + + +// We define these manually to ensure they're always copied +// even if they would move up the prototype chain +// https://nodejs.org/api/http.html#http_class_http_incomingmessage +const knownProperties = [ + 'aborted', + 'complete', + 'headers', + 'httpVersion', + 'httpVersionMinor', + 'httpVersionMajor', + 'method', + 'rawHeaders', + 'rawTrailers', + 'setTimeout', + 'socket', + 'statusCode', + 'statusMessage', + 'trailers', + 'url' +]; + +module.exports = (fromStream, toStream) => { + if (toStream._readableState.autoDestroy) { + throw new Error('The second stream must have the `autoDestroy` option set to `false`'); + } + + const fromProperties = new Set(Object.keys(fromStream).concat(knownProperties)); + + const properties = {}; + + for (const property of fromProperties) { + // Don't overwrite existing properties. + if (property in toStream) { + continue; + } + + properties[property] = { + get() { + const value = fromStream[property]; + const isFunction = typeof value === 'function'; + + return isFunction ? value.bind(fromStream) : value; + }, + set(value) { + fromStream[property] = value; + }, + enumerable: true, + configurable: false + }; + } + + Object.defineProperties(toStream, properties); + + fromStream.once('aborted', () => { + toStream.destroy(); + + toStream.emit('aborted'); + }); + + fromStream.once('close', () => { + if (fromStream.complete) { + if (toStream.readable) { + toStream.once('end', () => { + toStream.emit('close'); + }); + } else { + toStream.emit('close'); + } + } else { + toStream.emit('close'); + } + }); + + return toStream; +}; + + /***/ }), /***/ 2114: @@ -14658,77 +14703,32 @@ module.exports = object => { // We define these manually to ensure they're always copied // even if they would move up the prototype chain // https://nodejs.org/api/http.html#http_class_http_incomingmessage -const knownProperties = [ - 'aborted', - 'complete', +const knownProps = [ + 'destroy', + 'setTimeout', + 'socket', 'headers', + 'trailers', + 'rawHeaders', + 'statusCode', 'httpVersion', 'httpVersionMinor', 'httpVersionMajor', - 'method', - 'rawHeaders', 'rawTrailers', - 'setTimeout', - 'socket', - 'statusCode', - 'statusMessage', - 'trailers', - 'url' + 'statusMessage' ]; module.exports = (fromStream, toStream) => { - if (toStream._readableState.autoDestroy) { - throw new Error('The second stream must have the `autoDestroy` option set to `false`'); - } - - const fromProperties = new Set(Object.keys(fromStream).concat(knownProperties)); - - const properties = {}; + const fromProps = new Set(Object.keys(fromStream).concat(knownProps)); - for (const property of fromProperties) { - // Don't overwrite existing properties. - if (property in toStream) { + for (const prop of fromProps) { + // Don't overwrite existing properties + if (prop in toStream) { continue; } - properties[property] = { - get() { - const value = fromStream[property]; - const isFunction = typeof value === 'function'; - - return isFunction ? value.bind(fromStream) : value; - }, - set(value) { - fromStream[property] = value; - }, - enumerable: true, - configurable: false - }; + toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop]; } - - Object.defineProperties(toStream, properties); - - fromStream.once('aborted', () => { - toStream.destroy(); - - toStream.emit('aborted'); - }); - - fromStream.once('close', () => { - if (fromStream.complete) { - if (toStream.readable) { - toStream.once('end', () => { - toStream.emit('close'); - }); - } else { - toStream.emit('close'); - } - } else { - toStream.emit('close'); - } - }); - - return toStream; }; @@ -38004,6 +38004,10 @@ function postMessage() { function post(body) { return __awaiter(this, void 0, void 0, function* () { const url = core.getInput('url'); + if (!url) { + throw new Error('The "url" input is empty. Check that the secret is configured and passed correctly.\n' + + 'Note: repository secrets are unavailable to workflows triggered by fork pull requests.'); + } const rsp = yield got_1.default.post(url, { headers: { 'Content-Type': 'application/json' diff --git a/src/main.ts b/src/main.ts index 1258c27..3cc86d4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,6 +25,12 @@ async function postMessage(): Promise { async function post(body: Message): Promise { const url: string = core.getInput('url') + if (!url) { + throw new Error( + 'The "url" input is empty. Check that the secret is configured and passed correctly.\n' + + 'Note: repository secrets are unavailable to workflows triggered by fork pull requests.' + ) + } const rsp = await got.post(url, { headers: { 'Content-Type': 'application/json'