Closed vmandic closed 1 year ago
Not sure if I should've reported this to sentry-cli project as I looked up for this specific error string in your source and found some rust code possibly related to this: https://github.com/getsentry/sentry-cli/blob/033bd2173e3aeb82941913efdee4b80add99ea0c/src/api.rs#L1302-L1311
Seems HTTP 301/302 is handled as this error and you can see I exactly get it back: #25 27.81 DEBUG 2023-06-01 08:11:49.839525927 +00:00 response status: 302
?
Do you know maybe @bruno-garcia anything about this (asking you also because this might be a wrong project I reported to)?
Hi. Sorry for the delay.
When sentry-cli
reports "project not found" - it means that the combined org name and project name are not found using the configured auth token.
In your dockerfile, you specify -p:SentryOrg=Company -p:SentryProject=$SENTRY_PROJECT_NAME
. I presume Company
is replaced with your actual Sentry organization slug. Perhaps $SENTRY_PROJECT_NAME
is not resolving correctly?
Also, you can omit -p:UseSentryCLI=true
unless you've disabled it elsewhere. It doesn't hurt, it's just redundant.
Personally, I prefer to set most of the MSBuild properties in the .csproj
files themselves, or in a root Directory.Build.props
- but the command line approach should work the same.
You might try manually checking with sentry-cli --auth-token [your-auth-token] projects list --org [your-sentry-org]
to see if the project names are returned correctly. You might also want to echo the $SentryProject
variable from your dockerfile to make sure it's passed properly.
You might also be running into issues with the way dockerfile stages use environment variables. If you've got a multi-stage build (separated by FROM
statements in your dockerfile), then make sure the environment variable is set in the stage you're needing to use it. For example, if you're using the dockerfile standard file that's created by VS and Rider (for an ASP.NET Core project), it has build and publish in separate phases. You only need to use Sentry CLI in the build phase.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
# Pass when building the container: docker build --build-arg SENTRY_AUTH_TOKEN=[your-auth-token]
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
WORKDIR /src
COPY ["MyWebApp.csproj", "./"]
RUN dotnet restore "MyWebApp.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet build "MyWebApp.csproj" --no-restore -c Release -o /app/build
# In the publishing phase, we don't need to use Sentry CLI because it was already used in the build phase.
FROM build AS publish
RUN dotnet publish "MyWebApp.csproj" -c Release -o /app/publish -p:UseAppHost=false -p:UseSentryCLI=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyWebApp.dll"]
The above presumes setting <SentryOrg>
, <SentryProject>
, <SentryUploadSymbols>
, and <SentryUploadSources>
in the MyWebApp.csproj
file, or in a Directory.Build.props
file. Though if you prefer, you could pass them in the same way the auth token is passed.
Hope that helps.
@mattjohnsonpint, kind of a shame I did not verify names first, somehow we changed the names as a part of some cleanup and OFC it did not work. All good, thank you for the effort! Thanks, V.
Package
Sentry.AspNetCore
.NET Flavor
.NET
.NET Version
7.0.203
OS
Linux
SDK Version
3.31.0
Self-Hosted Sentry Version
No response
Steps to Reproduce
We observed a strange issue after upgrading from netcoreapp3.1 to net7 and disabling
PublishSingleFile
(due to #2362 which we also reported) (and thus also disablingReadyToRun
) and opting intoTieredPGO=true
; now debug/source upload is failing in our build pipeline job duringdotnet publish
and we lack source code in Sentry UI, and the error tells us that SentryCLI can't find the project like /source/Company.Project/Company.Project.csproj ... and then of course I went to check the docker image state, ie. the dirs and files at that point ofdotnet publish
(and before it) and the .csproj files ARE there.Here is the upload log output part from our docker build:
And if you wonder what the core parts of dockerfile look, here it is:
So I built the container locally and really verified the files are there, before and after publish.
Here is a screenshot from the container:
I enabled the debug logs (locally testing this and also same issue as on our CI job) for Sentry CLi and here is more detailed output for first project:
Same issue repeats for .pdb file.
Any ideas please? For now I will disable uploading sources as I can't see a way to pass this. :(
Sample issue ID where we noticed this: 4218503983, Project ID: 6323756
Expected Result
We expect the upload of sources and .pbd to pass as the .csproj files ARE in the place where the error reports they are not?!
Actual Result
Upload is skipped and the issues in Sentry lack source info and we cant view source code in the Sentry UI. Stack trace and line numbers are OK.