Commit Graph

37139 Commits

Author SHA1 Message Date
sourcegraph-buildkite
d498442148
security: Auto-update package lockfiles for Sourcegraph base images (#64035)
Automatically generated PR to update package lockfiles for Sourcegraph
base images.

Built from Buildkite run
[#283970](https://buildkite.com/sourcegraph/sourcegraph/builds/283970).
## Test Plan
- CI build verifies image functionality

Co-authored-by: Buildkite <buildkite@sourcegraph.com>
2024-07-24 11:46:40 +00:00
Release Bot
0f4cbff0ca
[Backport 5.5.x] Integrate security release approval into release pipeline (#64030)
As part of the [Vuln Scanning
Improvements](https://linear.app/sourcegraph/project/[p0]-vulnerability-scanning-improvements-75299c4312dd/issues)
project, I&#39;ve been working on tooling to automate the security
approval step of the release process.

This PR integrates these improvements into the release pipeline:

* Internal releases will run a vulnerability scan
* Promote-to-public releases will check for security approval

If a public release does not have security approval, it will block the
promotion process. The step happens at the start of the pipeline so
should be a fast-fail. You can also check for release approval before
running promotion by running `@secbot cve approve-release
&lt;version&gt;` in the #secbot-commands channel. In an ideal world we
(security) will have already gone through and approved ahead of release.

I&#39;ve tested this PR as much as I can without running an actual
release! We have a 5.5.x release tomorrow so it&#39;ll be a good test.
If it does cause problems that can&#39;t be easily solved, it can always
be temporarily disabled.

I&#39;ve tagged this PR to be backported to `5.5.x`.



## Pre-merge checklist

- [x] Revert commit that disables release promotion

## Test plan

Manual testing of the release process:
- [x] [Successful test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283774#0190dfd6-fa70-4cea-9711-f5b8493c7714)
that shows the security scan being triggered
- [x] [Promote to public test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283826) that
shows the security approval approving a release
- [x] [Promote to public test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283817#0190e0ec-0641-4451-b7c7-171e664a3127)
that shows the security approval rejecting a release with un-accepted
CVEs



## Changelog


 <br> Backport 9dd901f3c9 from #63990

Co-authored-by: Will Dollman <will.dollman@sourcegraph.com>
2024-07-24 10:42:33 +01:00
Release Bot
1a463ba167
[Backport 5.5.x] [logging] Only record events if a new user was created (#64005)
Follow-up on https://github.com/sourcegraph/sourcegraph/pull/63843

Based on comments from
[this](https://sourcegraph.slack.com/archives/C04RG0JD8L9/p1721668767261719?thread_ts=1721661216.365709&amp;cid=C04RG0JD8L9)
Slack thread, it seems like the events causing the spam are ones where a
new ext acct is saved without a user being created. So if we want to fix
the spam we need to only save an event if a user was created.



## Test plan

Test updated.



## Changelog


 <br> Backport 777c7a0899 from #64004

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.com>
2024-07-23 13:09:11 +01:00
Release Bot
074af1bda8
[Backport 5.5.x] Publish images for all commits on release branches (#63987)
In order to run nightly vulnerability scans of Sourcegraph releases, we
need to publish a new set of images whenever the release branch is
pushed to.

Previously, this was implemented in
https://github.com/sourcegraph/sourcegraph/pull/63379 but with RFC 795
the release branch format changed from 5.5.1234 to 5.5.x.

This PR updates the regex to catch this new format.

The end result of this is that whenever Buildkite runs on a branch
matching `\d.\d.x`, it will push images to the
`us.gcr.io/sourcegraph-dev/gitserver` registry with the tag
`$branch-insiders`.

I&#39;ve also tagged this PR for backport as we want it on the current
patch release branch 5.5.x :)



## Test plan

- Test buildkite run on branch `will-0.0.x` (with modified regex to
match that branch)
https://buildkite.com/sourcegraph/sourcegraph/builds/283608



## Changelog


 <br> Backport b7242d280f from #63985

Co-authored-by: Will Dollman <will.dollman@sourcegraph.com>
2024-07-22 16:22:32 +00:00
Release Bot
9522c46e6b
[Backport 5.5.x] [fix] Only trigger externalAcctSignup event when a new user is created (#63975)
Currently events are triggered whenever a user signs in with
`http-header` auth. This is because of the `GetAndSaveUser` function
always triggering an event.

However, before the new telemetry events, these events were only created
when a new user was created.

This PR brings the new telemetry code in line with the old telemetry
code to stop the massive amounts of spam caused by this event.

Closes SRC-461

## Test plan

Adjust expected events in unit test.



## Changelog

- Fixed an issue where the `http-header` auth would cause a massive
amount of event logs spam


 <br> Backport cd65951961 from #63843

Co-authored-by: Petri-Johan Last <petri.last@sourcegraph.com>
2024-07-22 13:06:38 +01:00
Camden Cheek
556b880329
Backport: Blame: fix some issues with the stream (#63865) (#63929)
Contributes to SRCH-738

Notably, this does not yet identify the root cause of SRCH-738, but it
does identify and fix some confounding bugs. It's possible that these
actually also _cause_ some of the issues in SRCH-738, but I wanted to at
least push these to dotcom, where we can reproduce some of the
weirdness. At the very least, it doesn't explain the auth errors being
reported.

(cherry picked from commit d91fab39e2)

Co-authored-by: Michael Bahr <michael.bahr@sourcegraph.com>
2024-07-22 10:43:52 +01:00
Michael Lin
3117b03be9
[Backport 5.5.x] Upgrade cody web experimental package to 0.2.7 (#63863) (#63901)
backport https://github.com/sourcegraph/sourcegraph/pull/63863

S2 Cody Web is broken at the moment. New client-config handlers fail
with 401 status because we don't send custom headers, this works for gql
queries since they all are POST requests and the browser automatically
sends an Origin header for them and this is enough for our auth
middleware to check cookies, but with client-config which is rest it's
not the case and we should send `X-Requested-Client: Sourcegraph` header
to make our auth middleware to pass this query correctly

Note that this problem doesn't exist in local builds since we proxy all
requests and add `X-Requested-Client: Sourcegraph` in dev server.

See Cody latest build PR for more details
https://github.com/sourcegraph/cody/pull/4898

## Test plan

CI

Co-authored-by: Vova Kulikov <vovakulikov@icloud.com>
2024-07-18 10:29:02 +01:00
Release Bot
9cf00da25a
[Backport 5.5.x] fix(batches): the baseURL for github instance is now updated when creating a GitHub app (#63833)
Closes SRCH-723

The baseURL for GitHub apps defaults to `https://github.com` when no
`externalServiceURL`, we somehow missed this during our testing.

![CleanShot 2024-07-12 at 11 57
00@2x](https://github.com/user-attachments/assets/99b68a11-de38-4a2d-8c4c-3219f0c9abf7)


## Test plan



Manual testing with the GHE instance.

## Changelog


 <br> Backport 1c40c9e5bc from #63803

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
Co-authored-by: Anish Lakhwara <anish+github@lakhwara.com>
2024-07-17 18:18:13 +00:00
Varun Gandhi
6b8d334563
Backport 63870 to 5.5.x (#63882)
See  https://github.com/sourcegraph/sourcegraph/pull/63870

cc @sourcegraph/release

## Test plan

Covered by existing tests

## Changelog

- Adds an experimental feature `commitGraphUpdates` to control how
upload visibility is calculated.
2024-07-17 13:45:36 -04:00
Release Bot
21247e44ac
[Backport 5.5.x] Upgrade cody web experimental package to 0.2.5 (#63856)
This PR upgrades the cody web experimental package to 0.2.5, in the new
version we fixed
- Telemetry problem with init extension-related events (we don&#39;t
send install extension events anymore)
- Most recent updates on LLM availability for enterprise instances 
 
## Test plan
- CI is green
- Manual check on basic Cody Web functionality (highly recommended) <br>
Backport e6bd85e4b7 from #63839

Co-authored-by: Vova Kulikov <vovakulikov@icloud.com>
2024-07-17 12:01:11 -04:00
Vova Kulikov
20adc60d67
[Backport-5.5.x]: Move Cody Web to beta (#63806) (#63808)
Closes

https://linear.app/sourcegraph/issue/CODY-2847/change-experimental-labels-to-beta

## Test plan
- Check that the cody web page and cody web side panel have beta badges

(cherry-picked from commit fbb0a1fec1)

## Test plan
- Check that the side-panel Cody and Cody Chat page have beta product
status badges
2024-07-15 12:07:10 -07:00
Release Bot
308624f144
[Backport 5.5.x] Context: return lines around symbol match (#63788)
This PR fixes an important bug in #62976, where we didn&#39;t properly
map the
symbol line match to the return type. Instead, we accidentally treated
symbol
matches like file matches and returned the start of the file.

## Test plan

Add new unit test for symbol match conversion. Extensive manual testing.
<br> Backport 004eb0fd83 from #63773

Co-authored-by: Julie Tibshirani <julietibs@apache.org>
2024-07-11 16:14:52 -04:00
Release Bot
174c08c8c2
[Backport 5.5.x] fix/alertmanager: downgrade prometheus/common to fix generated config (#63793)
The OTEL upgrade https://github.com/sourcegraph/sourcegraph/pull/63171
bumps the `prometheus/common` package too far via transitive deps,
causing us to generate configuration for alertmanager that altertmanager
doesn&#39;t accept, at least until the alertmanager project cuts a new
release with a newer version of `promethues/common`.

For now we forcibly downgrade with a replace. Everything still builds,
so we should be good to go.

## Test plan
`sg start` and `sg run prometheus`. On `main`, editing
`observability.alerts` will cause Alertmanager to refuse to accept the
generated configuration. With this patch, all is well it seems - config
changes go through as expected. This is a similar test plan for
https://github.com/sourcegraph/sourcegraph/pull/63329

## Changelog

- Fix Prometheus Alertmanager configuration failing to apply
`observability.alerts` from site config <br> Backport
ffa873f3ad from #63790

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
2024-07-11 15:49:58 -04:00
Release Bot
8ee41490b9
[Backport 5.5.x] release/bug: generate a new stitched migration graph (#63769)
This will correct6 upgrade path for mvu plan creation

## Test plan

CI test



## Changelog


 <br> Backport cb19d6f0a9 from #63764

Co-authored-by: Warren Gifford <warren@sourcegraph.com>
2024-07-10 22:01:36 +00:00
Release Bot
344169fd47
[Backport 5.5.x] chore(release): bump stitch graph generation (#63768)
Missing bit for the minor release version bump

## Test plan

CI


 <br> Backport 087ad83995 from #63767

Co-authored-by: Jean-Hadrien Chabran <jean-hadrien.chabran@sourcegraph.com>
2024-07-10 21:00:59 +00:00
Anish Lakhwara
d47b4cc48b
fix(build): update wolfi image lock for otel (#63755)
<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->
We need to update the wolfi lock image for
https://github.com/sourcegraph/sourcegraph/pull/63171 in order for `sg
run` to work

We've made all the changes to the deployment repos for this to be pushed
out in the release today.

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
Manually tested

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
- fix(build): update wolfi lock for otel-collector
2024-07-10 10:23:11 -07:00
Bolaji Olajide
c712d8d087
chore: add changelog entry for Batch Changes <> GitHub apps integration (#63756)
Changelog update

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
N/A

## Changelog

* Batch Changes: GitHub apps can now be added as a credential for
authentication and interacting with changesets.
[#31533](https://github.com/sourcegraph/sourcegraph/issues/31533)
2024-07-10 16:26:01 +00:00
Robert Lin
7d91894a01
chore/otel-collector: upgrade to v0.103.0, remove jaegerexporter (#63171)
Thread:
https://sourcegraph.slack.com/archives/C1JH2BEHZ/p1717797870638299

One problem caused by this upgrade is that the [deprecated
`jaegerexporter`](https://github.com/open-telemetry/opentelemetry-specification/pull/2858)
no longer builds at all with the last published version, so for the
upgrade to go through it must be removed. I've updated local `sg start`
to work with this change, but some Release team support is needed for
deployment configuration + customer-facing docs changes:
https://sourcegraph.slack.com/archives/C1JH2BEHZ/p1718143249191349?thread_ts=1717797870.638299&cid=C1JH2BEHZ,
since current guidance asks customers to configure `jaegerexporter`.

Part of https://linear.app/sourcegraph/issue/SEC-1680

Closes https://linear.app/sourcegraph/issue/CORE-177

## Test plan

Followed steps shared in
https://sourcegraph.slack.com/archives/C04MYFW01NV/p1718136211292469 to
run locally, since `sg run jaeger otel-collector` alone is insufficient
to get updated images:

```diff
diff --git a/wolfi-images/opentelemetry-collector.yaml b/wolfi-images/opentelemetry-collector.yaml
index b995a3d531b..76de80d4f84 100644
--- a/wolfi-images/opentelemetry-collector.yaml
+++ b/wolfi-images/opentelemetry-collector.yaml
@@ -7,7 +7,11 @@ contents:
     - mailcap
 
     ## opentelemetry-collector packages
-    - opentelemetry-collector@sourcegraph
+    - opentelemetry-collector@branch
+  keyring:
+    - https://packages.sgdev.org/sourcegraph-melange-dev.rsa.pub
+  repositories:
+    - '@branch https://packages.sgdev.org/branches/otel-collector-upgrade'
 
 paths:
   - path: /otel-collector
```

plus `sg wolfi lock opentelemetry-collector` will make `sg run
otel-collector` use the correct image.

**The above diffs SHOULD NOT be committed. The lock should happen
post-merge.**

Spot-checked some traces locally with:

```
sg run jaeger otel-collector
sg start
```


![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/dff88d5a-db9a-4039-b7ba-682e120bdc41)


![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/7e553894-0026-47de-ae38-ba5502b94c63)


## Changelog 

- OpenTelemetry Collector: Upgraded OpenTelemetry Collector to v0.103.0
- OpenTelemetry Collector: The [deprecated `jaegerexporter` has been
removed](https://github.com/open-telemetry/opentelemetry-specification/pull/2858).
Users of `exporter: { jaeger: ... }` in the OpenTelemetry Collector
should use `exporter: { otlp/jaeger: ... }` to send traces directly to
Jaeger via its OTLP receiver.
- Users of the default Jaeger configurations now need to provide
`JAEGER_OTLP_GRPC_PORT` as well as the existing `JAEGER_HOST`
configuration.

---------

Co-authored-by: Anish Lakhwara <anish+github@lakhwara.com>
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com>
2024-07-10 09:01:41 -07:00
Petri-Johan Last
23128d1489
fix(perforce) Fix support for p4breaker workaround scripts (#63611) 2024-07-10 17:39:54 +02:00
Camden Cheek
52ebd70bd0
Chore: remove gorilla/schema (#63738)
We created a decoder that was never used, but the package is otherwise
unused. It recently had a CVE, so this just removes it so it's no longer
part of our security surface area.
2024-07-10 15:36:37 +00:00
Craig Furman
824116eca8
chore(appliance): SetupEnvtest returns k8s config, not client (#63749)
Make SetupEnvtest slightly lower-level by asking callers to construct
their own client from the returned k8s REST config. This is because
there are 2 kinds of official kubernetes client in Go - a
kubernetes.Clientset and a client.Client. The latter is
more-traditionally used in operators, because it's what a
ControllerManager.GetClient() returns, and indeed this is what our
reconciler uses.

We ended up using a kubernetes.Clientset in the envtest-using golden
tests for the reconciler, because its mechanics for listing resources
were simpler. Now, I want to reuse SetupEnvtest somewhere that needs a
client.Client. We could undertake work to use only one flavor of
kubernetes client, but this commit seems like a decent low-cost first
step.
2024-07-10 14:59:09 +01:00
Bolaji Olajide
43f907f8a9
fix(batches): enable check for creating source as non credential (#63751)
This check was wrong as we create a non-credential source only when the
ChangesetSource strategy isn't `GitHubApp`

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-10 13:58:13 +00:00
Shivasurya
9e95499625
chore(security) : upgrade src-cli version to address CVE (#63750)
Docker images executor, executor-kubernetes, bundled-executor has
reported high/critical CVE-2024-24790 , CVE-2023-45288 reported on
golang stdlib. Upon testing, src version 5.3.0 was using `1.20.x` as per
e8e79e0311

This pull request attempts to upgrade src version to 5.4.0

## Test plan

- CI 🟢 
- src version should report 5.4.0 (I built the image locally and tested
it)
`docker run --platform linux/amd64 -it --entrypoint /bin/sh
executor:candidate`

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

Upgrade src-cli version to 5.4.0 to address CVE-2024-24790 ,
CVE-2023-45288
2024-07-10 09:57:16 -04:00
Christoph Hegemann
d3df71ef98
Adds a test for search-based usages (#63610)
Closes
https://linear.app/sourcegraph/issue/GRAPH-726/test-syntactic-and-search-based-usages

Testing just the search-based usages just requires mocking the
SearchClient, which works out nicely.

## Test plan

The whole PR is just a test
2024-07-10 13:22:53 +00:00
Jean-Hadrien Chabran
2645a9b04d
chore(migrator): bump migration archive (#63752)
Routine update, as this is still a manual process.

## Test plan

CI
2024-07-10 15:10:32 +02:00
Nelson Araujo
08ed73cd3d
Convert Appliance Maintenance UI to Bazel (#63661)
Write Bazel machinery for the Appliance maintenance UI.

## Test plan

- `bazel build ...` passes
- `pnpm run dev` launches app successfully

---------

Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
2024-07-10 13:47:18 +02:00
William Bezuidenhout
ddc27b887f
feat(sg/cloud): trigger build on cloud-ephemeral pipeline (#63748)
Currently if a cloud ephemeral build is trigger it is triggered on the
`main` sourcegraph pipeline. Once a build a triggered and a commit is
subsequently pushed the previous build is cancelled - which means the
Cloud Ephemeral build is cancelled leading to a failed deployment.

In this PR, we instead trigger a build on the Cloud Ephemeral pipeline.
Which is the _exact_ pipeline as `sourcegraph` main but:
- sets the pipeline env to always have `CLOUD_EPHEMERAL=true`
- does not cancel previous builds

## Test plan
https://buildkite.com/sourcegraph/cloud-ephemeral/builds/1


## Changelog
* `sg cloud eph` will now trigger builds on the `cloud-ephemeral`
pipeline
2024-07-10 11:58:46 +02:00
Varun Gandhi
743134a193
docs: Fix inaccuracies in RangeInput GraphQL docs (#63640) 2024-07-10 09:47:10 +00:00
sourcegraph-buildkite
8efbdc2d49
security: Auto-update package lockfiles for Sourcegraph base images (#63606)
Automatically generated PR to update package lockfiles for Sourcegraph
base images.

Built from Buildkite run
[#281769](https://buildkite.com/sourcegraph/sourcegraph/builds/281769).
## Test Plan
- CI build verifies image functionality

Co-authored-by: Buildkite <buildkite@sourcegraph.com>
2024-07-10 09:21:27 +01:00
Felix Kling
a8639c1328
chore(svelte): Update cody web version (#63747)
Similar to https://github.com/sourcegraph/sourcegraph/pull/63742 this
updates to the latest cody web version in the new web app.

## Test plan

Manual testing
2024-07-10 07:58:21 +00:00
Michael Bahr
bd1488167f
fix: remove watch path that's gone (#63746)
https://github.com/sourcegraph/sourcegraph/pull/63736 removed rockskip
files, which lead to `sg start` failing because it was still watching
those. This PR removes the watch and lets `sg start` succeed again.

## Test plan

Existing CI, manual test of `sg start`

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-10 06:56:25 +00:00
Vova Kulikov
fea468bd14
Bump cody-web-experimental to 0.2.4 (#63742)
Follow up for https://github.com/sourcegraph/cody/pull/4826

In the latest release, 0.2.4, we fixed the problem that @fkling found
about links
[here](https://linear.app/sourcegraph/issue/SRCH-633/links-in-the-prompt-has-incorrect-url-in-cody-web#comment-b9427c46);
cody assistance can render links in its response via markdown, and in
0.2.3, these links had deep link vscode command, which didn't work
properly in cody web. Now it renders plain links when it's rendered for
Cody Web.

## Test plan
- Check that links that Cody assistance provides work properly and don't
have any deep links command

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 21:23:08 -06:00
Erik Seliger
2e392e0e89
Unexport some externally irrelevant symbols from uploadstore (#63647)
These symbols aren't used outside of the package, so unexporting them
for a cleaner API surface.

Test plan:

Go compiler doesn't complain.
2024-07-10 02:45:02 +02:00
Erik Seliger
9435fde3a2
Remove unused package (#63646)
This package isn't in use anymore, so cleaning it up.

Test plan:

Go compiler doesn't complain.
2024-07-10 02:30:28 +02:00
Erik Seliger
eb39e68761
scheduler: Simplify query for uncloned repos (#63681)
Since we removed on-demand cloning, the scheduler is now expected to always contain all repositories. Thus, we no longer need to constrain the set of uncloned repos to a ginormous ID list.

Test plan:

CI still passes.
2024-07-10 02:24:32 +02:00
Erik Seliger
8bc8ad27bd
phabricator: Move syncer to worker (#63682)
This syncer doesn't depend on anything in repo updater, so we're moving it to worker instead, where it can selectively be disabled and is properly monitored.

Test plan:

CI passes, code review.
2024-07-10 02:24:18 +02:00
Erik Seliger
ac0d497315
Remove old cache cleanup method (#63645)
We have been using v2 data since >5 years now, this should be safe to
remove.

As a side-effect, we have one less background task running in frontend,
which means it ran N times in horizontally scaled environments, which
isn't exactly useful.

Test plan:

Code review.
2024-07-10 02:04:53 +02:00
Erik Seliger
a32b6131f3
codygateway: Use only one redis pool and make REDIS_ENDPOINT a clear requirement in config (#63625)
Currently, nothing really tells that Cody Gateway needs redis, the env
var for finding the address is hidden somewhere deep in the redispool
package.
In practice, we only use one redis instance, but at some point we
started using both redispool.Cache and redispool.Store, which means we
maintain two connection pools, leading to more than expected
connections.

Test plan:

Code review and CI.
2024-07-10 01:54:24 +02:00
Erik Seliger
41fdc5cc7c
symbols: Make symbols specific code internal (#63736)
This PR restructures the packages to move all symbols-only code into the
symbols service. This helps to reason better about which service is
accessing what datastores.

Test plan:

Just moved code, compiler and CI are happy.
2024-07-10 01:26:22 +02:00
Erik Seliger
169db11ce6
rcache: Explicitly pass redis pool to use (#63644)
Recently, this was refactored to also allow using the redispool.Store.
However, that makes it very implicit to know where something is being
written, so instead we pass down the pool instance at instantiation.

This also gives a slightly better overview of where redispool is
actually required.

Test plan: CI passes.
2024-07-10 01:23:19 +02:00
Erik Seliger
60dc37d1a5
symbols: Minor code cleanup (#63708)
Was reading through the service, found these things and figured why not
commit them.

Test plan:

CI.
2024-07-10 01:22:03 +02:00
Stephen Gutekanst
bd3baef6e0
pass ModelConfigInfo down to client.Get() for self-hosted-models (#63739)
This PR has a single goal: pass a new `ModelConfigInfo` type, which has
the `Provider` and `Model` we should use to serve a completions request,
down into `client.Get()`

This PR explicitly only handles the case we care about for Self-hosted
models, and all pieces of logic that I expect will be
replaced/superseded by your work @chrsmith are annotated with `//
TODO(slimsag): self-hosted-models:` comments so we can easily find and
remove them when your work is ready.

Every location I have modified has been carefully wrapped in an if
statement like `if conf.Get().SiteConfig().ModelConfiguration != nil` to
ensure that this change _only_ affects people who set the new
`"modelConfiguration"` site config property.

## Test plan

1. Configured `"modelConfiguration"` and removed `"completions"` in my
dev instances' site config.
2. Used VS Code chat to confirm I see this codepath is connected
end-to-end and I get a `TODO` error back:

<img width="679" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/3173176/d3c07ffe-7ec2-4ad9-9251-2272ce36d44b">

## Changelog

N/A

---------

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
2024-07-09 15:30:37 -07:00
Felix Kling
82372119fe
fix(svelte): Prefill search home page query input with (default) context filter (#63740)
Closes srch-103

Currently we don't show the global context filter on the search home
page or the search results page (global context is the default context).

This commit does two things:

- It prefills the search input on the search homepage with the user's
default context (like the React app)
- It the logic that pre-processed the search query and removed the
context filter if it was global.

In other words we simplify the query logic by showing/submitting the
search query as is. Notably this doesn't affect how the search input
works on repo pages.


## Test plan

- Opening the search home page pre-fills the query input with the
default search context
- Submitting a query without a `context:` filter does not add a
`context:` filter to the URL or the search input
- If a query contains `context:global` that filter is preserved in the
query input (it wasn't before)
2024-07-09 22:02:04 +00:00
Felix Kling
b9dd3a774d
chore(svelte): Use MDI icons for seach input pattern type toggles (#63733)
We don't like the style/alignment of the Lucide case sensitivity and
regex icons (the structural search icon seems fine). This commit
switches them back to the MDI icons that we used before.

Solution or temporary workaround (tbd) for srch-544


## Test plan

Manual testing.
2024-07-09 21:56:00 +00:00
Matthew Manela
4c3985e16f
feat(Source): Properly render multi-line changelist messages from Perforce (#63728)
Fixes SRC-431

Mutli-line perforce changelist descriptions were not being handle since
the code implicitly assumed they could not exist. This change enables
support for them.


## Screenshots

**Changelist view with both single and multiline commits**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/8c7ead01-fdec-461c-826b-83013f89ad77)

**Changelist view with expanded commit message**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/a16c8637-7180-4631-88cb-39b4cc49a74c)

**Individual changelist item**

![image](https://github.com/sourcegraph/sourcegraph/assets/304410/c63f0a49-f6a9-430c-9caf-0480c17bb64e)


## Test plan
1. Update unit tests
2. Validate both P4 and non-p4 commits work
3. Validate on s2

## Changelog

- Properly render multi-line perforce changelist descriptions
2024-07-09 17:52:05 -04:00
Robert Lin
28f797e866
feat/enterpriseportal: database layer for subscriptions upsert (#63703)
Implements upsert for all the subscriptions fields in the DB client. As
part of this I generalized the logic for building upsert DB interactions
into a new `upsert` package, because this pattern is a common one we'll
need to implement to maintain various AIP-update-compliant endpoints,
which specifies various upsert behaviours: https://google.aip.dev/134

Part of CORE-216
Part of CORE-156

## Test plan

Integration tests against DB
2024-07-09 14:35:00 -07:00
Robert Lin
d7ab268385
feat/dotcom: add Enterprise Portal auth proxy (#63652)
Part of https://linear.app/sourcegraph/issue/CORE-211

This introduces authenticated proxies that allow dotcom site admins
access to dev and production Enterprise Portal instances, authenticated
with client credentials issued to the dotcom instance. The medium-term
goal is to use this proxy so that we can use the existing subscriptions
UI, backed by the new Enteprise Portal deployments (e.g.
https://github.com/sourcegraph/sourcegraph/pull/63653, tracking issue:
https://linear.app/sourcegraph/issue/CORE-100/enterprise-portal-migrate-away-from-dotcom-db-as-source-of-truth),
until we have a dedicated UI for Enterprise Portal
(https://linear.app/sourcegraph/project/kr-p-enterprise-portal-user-interface-dadd5ff28bd8)

This is required until we ship
https://linear.app/sourcegraph/project/kr-p1-streamlined-role-assignment-via-sams-and-entitle-2f118b3f9d4c/overview,
which will allow SAMS to be the source-of-truth for who is a site admin
in Sourcegraph.com. Once we have that information, we can use the user's
SAMS session directly in Enterprise Portal to authorize access to
Enterprise Portal data.

## Test plan

Set up `dev-private` with dev credentials:
https://github.com/sourcegraph/dev-private/pull/101

`sg start dotcom`, create a personal access token, and try to make
ConnectRPC requests matching the spec to the new endpoints:

```sh
# Local
curl --header "Content-Type: application/json" --header "authorization: token sgp_local_..." --data '{"filters":[{"filter":{"is_archived":false}}]}' -v  \
    https://sourcegraph.test:3443/.api/enterpriseportal/local/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions
# Dev
curl --header "Content-Type: application/json" --header "authorization: token sgp_local_..." --data '{"filters":[{"filter":{"is_archived":false}}]}' -v  \
    https://sourcegraph.test:3443/.api/enterpriseportal/dev/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions
```

Note that the URL path after `/.api/enterpriseportal/dev/`, i.e.
`/enterpriseportal.subscriptions.v1.SubscriptionsService/ListEnterpriseSubscriptions`,
and the shape of the parameters, are all the same as if you curl'd the
Enterprise Portal API directly, per the Connect protocol:
https://connectrpc.com/docs/protocol/

Both local and dev reach out to the existing SAMS dev deployment for
credentials, so the `dev-private` credentials work OOTB for both.

---------

Co-authored-by: Andre Eleuterio <andreeleuterio@users.noreply.github.com>
2024-07-09 13:46:59 -07:00
Felix Kling
160d1bf56d
chore(svelte): Update to latest cody web version (#63732)
Yet another PR to get cody web up-to-date in the new web app.

## Test plan
Manual testing.
2024-07-09 20:22:18 +00:00
Chris Smith
232cfcb097
Several refactoring to prepare for rolling out modelconfig (#63731)
This PR bundles several small refactoring to make it easier to review
the pending "refactor completion APIs to read from modelconfig".

Going commit-by-commit:

[Export the ValidateModelRef
function](3c949a88d0)

This just exports a validation function that was previously private from
the `internal/modelconfig` package. We'll be using this to sanity check
the `ModelRef` that is returned from the "getModelsFn".


[Add modelconfig.{InitMock,
ResetMock}](f807f40bf5)

In order to update the `frontend/internal/httpapi/completions` unit
tests, we need to have changes to the site configuration data _ALSO_
update the global `modelconfig.Service`. Typically this would happen by
a "config watcher" that gets registered, but we don't do that as part of
unit tests.

So instead, I just added some clunky `InitMock() error` and `ResetMock()
error` functions to support unit testing. If you have a better idea for
how to expose this behavior, I'm all ears.

[Move fireworks-specific API types into
types.go](bb02ccba45)

Moves the API data types for the `fireworks` client into their own file,
just to keep things tidy.

[Refactor completion
clients](02a5e3bfc9)

This is a bit involved, but from a high-level, we are just passing the
`types.CompletionRequest` object "lower" into the call stack. Rather
than only return the `.Parameters` field
(`types.CompletionRequestParameters`).

This is necessary, because I plan on adding another field to
`types.CompletionRequest` (to include the `modelconfig.Provider` and
`modelconfig.Model` data). So this change just does some of the work for
that now, resulting in a smaller and easier to review diff later.

Also, in some cases I moved the calls to
`tokenManager.UpdateTokenCountsFromModelUsage` into a dedicated function
to simplify the callsites.

## Test plan

Existing unit tests

## Changelog

NA
2024-07-09 13:16:36 -07:00
Erik Seliger
df4c636dc5
squirrel: Correctly use request context (#63729)
The ctx parameter was unused, and I noticed that the parser is called
without the request context. Fixing that here.

Test plan:

Code review and CI.
2024-07-09 22:06:01 +02:00