Skip to content
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

[ResponseOps] Slack webapi does not work with proxies #168701

Closed
pmuellr opened this issue Oct 12, 2023 · 2 comments
Closed

[ResponseOps] Slack webapi does not work with proxies #168701

pmuellr opened this issue Oct 12, 2023 · 2 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Actions/ConnectorTypes Issues related to specific Connector Types on the Actions Framework Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@pmuellr
Copy link
Member

pmuellr commented Oct 12, 2023

We received a support request for Slack not working with a proxy, and the following message logged:

error determining proxy state for invalid url "conversations.list?types=public_channel,private_channel", using default agents

Looking at the relevant code, it looks like the Slack API connector is using axios a bit differently than other connectors. It sets the domain name when creating the axios instance, and passes a domain-less url into the request() function. That url (without the domain) is what we are using to determine whether to use the proxy, and it can't figure it out (the error message), so it doesn't use the proxy.

relevant code:

const axiosInstance = axios.create({
baseURL: SLACK_URL,
headers: {
Authorization: `Bearer ${token}`,
'Content-type': 'application/json; charset=UTF-8',
},
});
const validChannelId = async (
channelId: string
): Promise<ConnectorTypeExecutorResult<ValidChannelResponse | void>> => {
try {
const validChannel = (): Promise<AxiosResponse<ValidChannelResponse>> => {
return request<ValidChannelResponse>({
axios: axiosInstance,
configurationUtilities,
logger,
method: 'get',
url: `conversations.info?channel=${channelId}`,
});
};

export const request = async <T = unknown>({
axios,
url,
logger,
method = 'get',
data,
configurationUtilities,
headers,
sslOverrides,
...config
}: {
axios: AxiosInstance;
url: string;
logger: Logger;
method?: Method;
data?: T;
configurationUtilities: ActionsConfigurationUtilities;
headers?: Record<string, AxiosHeaderValue>;
sslOverrides?: SSLSettings;
} & AxiosRequestConfig): Promise<AxiosResponse> => {
const { httpAgent, httpsAgent } = getCustomAgents(
configurationUtilities,
logger,
url,
sslOverrides
);
const { maxContentLength, timeout } = configurationUtilities.getResponseSettings();

// there is a proxy in use, but it's possible we won't use it via custom host
// proxyOnlyHosts and proxyBypassHosts
let targetUrl: URL;
try {
targetUrl = new URL(url);
} catch (err) {
logger.warn(`error determining proxy state for invalid url "${url}", using default agents`);
return defaultAgents;
}

If that assumption is correct, this will require a code fix on our part, I don't believe there is a work-around possible.

@pmuellr pmuellr added bug Fixes for quality problems that affect the customer experience Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Actions/ConnectorTypes Issues related to specific Connector Types on the Actions Framework labels Oct 12, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@ymao1
Copy link
Contributor

ymao1 commented Oct 12, 2023

cc @XavierM

@ymao1 ymao1 moved this from Awaiting Triage to Todo in AppEx: ResponseOps - Execution & Connectors Oct 12, 2023
@XavierM XavierM self-assigned this Oct 17, 2023
@XavierM XavierM moved this from Awaiting Triage to In Progress in AppEx: ResponseOps - Rules & Alerts Management Oct 17, 2023
@XavierM XavierM moved this from In Progress to In Review in AppEx: ResponseOps - Rules & Alerts Management Oct 18, 2023
XavierM added a commit that referenced this issue Oct 18, 2023
## Summary

FIX -> #168701


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 18, 2023
## Summary

FIX -> elastic#168701

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 7df3f96)
kibanamachine referenced this issue Oct 18, 2023
# Backport

This will backport the following commits from `main` to `8.11`:
- [[RAM] fix Slack API proxy
(#169171)](#169171)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Xavier
Mouligneau","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-18T18:03:47Z","message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v8.11.0","v8.12.0","v8.10.4"],"number":169171,"url":"https://github.com/elastic/kibana/pull/169171","mergeCommit":{"message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5"}},"sourceBranch":"main","suggestedTargetBranches":["8.11","8.10"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/169171","number":169171,"mergeCommit":{"message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5"}},{"branch":"8.10","label":"v8.10.4","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Xavier Mouligneau <[email protected]>
XavierM added a commit to XavierM/kibana that referenced this issue Oct 18, 2023
FIX -> elastic#168701

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 7df3f96)
XavierM referenced this issue Oct 23, 2023
# Backport

This will backport the following commits from `main` to `8.11`:
- [[RAM] fix Slack API proxy
(#169171)](#169171)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Xavier
Mouligneau","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-18T18:03:47Z","message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v8.11.0","v8.12.0","v8.10.4"],"number":169171,"url":"https://github.com/elastic/kibana/pull/169171","mergeCommit":{"message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5"}},"sourceBranch":"main","suggestedTargetBranches":["8.11","8.10"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/169171","number":169171,"mergeCommit":{"message":"[RAM]
fix Slack API proxy (#169171)\n\n## Summary\r\n\r\nFIX ->
https://github.com/elastic/kibana/issues/168701\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"7df3f964ce31285162dd8bc7d3850691872d01d5"}},{"branch":"8.10","label":"v8.10.4","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@XavierM XavierM closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Actions/ConnectorTypes Issues related to specific Connector Types on the Actions Framework Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
No open projects
Development

No branches or pull requests

4 participants