mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 14:36:33 +00:00
fix: empty project by id (#393)
* fix: check if project found in by id * fix: check length of events
This commit is contained in:
parent
4b58097cca
commit
59ac7f051f
@ -34,17 +34,21 @@ type ProjectRepo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) ProjectByID(ctx context.Context, id string) (*proj_model.ProjectView, error) {
|
func (repo *ProjectRepo) ProjectByID(ctx context.Context, id string) (*proj_model.ProjectView, error) {
|
||||||
project, err := repo.View.ProjectByID(id)
|
project, viewErr := repo.View.ProjectByID(id)
|
||||||
if err != nil && !caos_errs.IsNotFound(err) {
|
if viewErr != nil && !caos_errs.IsNotFound(viewErr) {
|
||||||
return nil, err
|
return nil, viewErr
|
||||||
}
|
}
|
||||||
if caos_errs.IsNotFound(err) {
|
if caos_errs.IsNotFound(viewErr) {
|
||||||
project = new(model.ProjectView)
|
project = new(model.ProjectView)
|
||||||
}
|
}
|
||||||
|
|
||||||
events, err := repo.ProjectEvents.ProjectEventsByID(ctx, id, project.Sequence)
|
events, esErr := repo.ProjectEvents.ProjectEventsByID(ctx, id, project.Sequence)
|
||||||
if err != nil {
|
if caos_errs.IsNotFound(viewErr) && len(events) == 0 {
|
||||||
logging.Log("EVENT-V9x1V").WithError(err).Debug("error retrieving new events")
|
return nil, caos_errs.ThrowNotFound(nil, "EVENT-8yfKu", "Errors.Project.NotFound")
|
||||||
|
}
|
||||||
|
|
||||||
|
if esErr != nil {
|
||||||
|
logging.Log("EVENT-V9x1V").WithError(viewErr).Debug("error retrieving new events")
|
||||||
return model.ProjectToModel(project), nil
|
return model.ProjectToModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user